![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | 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 here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [Urgent]how to print the file names into a txt file??? | kumarsaravana_s | Shell Programming and Scripting | 15 | 03-11-2007 11:32 PM |
| Reducing file names | paul1s | UNIX for Dummies Questions & Answers | 5 | 10-12-2006 04:54 AM |
| Reading file names from a file and executing the relative file from shell script | anushilrai | Shell Programming and Scripting | 4 | 03-10-2006 01:25 AM |
| File names | giantflameeater | UNIX for Dummies Questions & Answers | 9 | 11-24-2004 03:03 PM |
| Getting all file names in a folder. | adadevil | UNIX for Dummies Questions & Answers | 5 | 06-28-2001 01:30 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
To get the file names.
Hi,
I have written a shell script which selects the particular type of file (consider that .xml files) from each sub directories under a parent directory and does some manipulation. Now what happens here at a time it looks for asingle sub directory only. I mean it is executed recursively for each sub directory. Now my intent is to select all the .xml files from all subdirectories and to do some manipulation on the oldest file among all files. How it can be done? what I did : I selected all the files from each directory and redirected to them a flat file using command: ls -lurt $dir/*.xml | awk '{print $6,$7,$8,$9}'>> tmp.txt. from tmp.txt I can find the file name with full path using the command: cut -d' ' -f4 tmp.txt Now I faced difficult to sort the files which are in tmp.txt file. |
| Forum Sponsor | ||
|
|
|
|||
|
Using GNU tools you can do:
numfiles=10 #number to process find $dir -name "*.xml" -printf "%T@\t%p\n" | sort -k1,1n | tail -$numfiles | cut -f2- | while read file; do echo processing $file done For comparison have a look at: http://www.pixelbeat.org/scripts/newest |
|||
| Google The UNIX and Linux Forums |