Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Open a random file in the GUI via a bash script' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Open a random file in the GUI via a bash script
Authored by: gshenaut on Nov 14, '05 09:25:29AM
Well, if the files are all at the same level in the folder, you could use
ls *.{doc,rtf,txt}
to get the files. You might be able to use something like
i=$(( 1 + $RANDOM % $(ls *.{rtf,txt,doc} | wc -l) ))
open `ls *.{rtf,txt.doc} | sed -e ${i}p -e d`
(I use ksh, bash may be slightly different.)

Greg Shenaut

[ Reply to This | # ]