1: #!/bin/ksh 2: 3: # Select a random image from the background logo collection 4: # This could be used to configure a screen saver, for example. 5: # 6: # This works even if the filenames contain spaces. 7: 8: # switch to the logos directory to avoid long paths 9: logos=/afs/northstar/common/usr/lib/X11/logos/backgrounds 10: cd $logos 11: 12: # '*' is a filename wildcard to match all files in the current directory 13: set * 14: 15: # Use the syntax for arithmetic expressions. "%" is the modulo operator 16: # Shift arguments by a random number between 0 and the number of files 17: shift $(($RANDOM % $#)) 18: 19: # Output the resulting first argument 20: echo "$logos/$1"
last modified 22/03/2012 | Introduction | Table of Contents (frame/no frame) |
Printable (single file) |
© Dartmouth College |