![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| $random | relle | Shell Programming and Scripting | 6 | 07-11-2008 06:59 AM |
| How to read and write a random row from a file? | sashankkrk | UNIX for Dummies Questions & Answers | 9 | 05-13-2008 08:26 AM |
| [C++] File I/O (Reading from a Random-Access File) | VersEtreOuNe | High Level Programming | 0 | 02-12-2008 04:34 PM |
| random in ksh | pascalbout | AIX | 1 | 01-04-2006 10:53 AM |
| Sed - Replacing numbers w/asteriks in random location in a file | giannicello | UNIX for Dummies Questions & Answers | 9 | 10-04-2001 01:03 AM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Getting a random file
Hello, I am very new to shell scripting. This problem seems quite easy so it should be quite easy (I hope ^^)
I want to get a random file from a directory. this file will be in one subdirectory, and it will contain spaces. code I have got so far: N=find ./*/*.jpg | wc -l ((N=RANDOM%N)) That gives me a number. Now I want to select the Nth file in this file list generated by find ./*/*.jpg I wanted to use echo ./*/*.jpg except that gave me spaces as a delimiter, which is kind of stupid ^^, since file names contain spaces |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|