![]() |
|
|
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 |
| find command in while loop - how to get control when no files found? | mavsman | Shell Programming and Scripting | 3 | 04-03-2008 12:44 PM |
| getting error 0403-016 Cannot find or open the file while reading a long line | karthee | Shell Programming and Scripting | 2 | 06-05-2005 01:00 AM |
| ls -l output with long iso format | rofflox | Shell Programming and Scripting | 1 | 04-16-2004 10:46 AM |
| command find returned bash: /usr/bin/find: Argument list too long | yacsil | Shell Programming and Scripting | 1 | 12-15-2003 06:38 PM |
| solaris2.6 command to find/list system configuration | subhransu | UNIX for Dummies Questions & Answers | 4 | 05-01-2001 02:39 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Help with find command and list in a long format each found file
The purpose of those comands are to find the newest file in a directory acvrdind to system date, and it has to be recursively found in each directory.
The problem is that i want to list in a long format every found file, but the commands i use produce unexpected results ,so the output lists in a long format the files located in the path working directory. ie i tried 2 ways but not working 1. touch -t YYYYMMDD filename. ok 2. find -newer filename -exec ls -lrt ´{} \; · It doesn work the second trial i used is: find -newer filename > anotherfile while read ine do ls -lrt "$line" done < another file In the above examples keeps listing files located in the path working directory not the desired files (The newest one en each directory) Why this happens? id appreciate any help and your support gurus. Thanks ie output |
|
||||
|
finding out the problem ive got part of the solutionin this way:
find /bmd -type f -newer $anio$mes$dia$hora$minuto -exec ls -lrtd {} \; (previously definig the variables Output -rw-r----- 1 ftp_coll ict 3251584 Dec 9 23:30 /bmd/boboprd/input/BOBOBSC25480920071209233010000.intec -rw-r----- 1 ftp_coll ict 2518526 Dec 9 23:49 /bmd/boboprd/input/BOBOBSC25481020071209234956000.intec -rw-r----- 1 ftp_coll ict 454771 Dec 10 00:00 /bmd/boboprd/BOBOBSC25481120071210000004000.intec -rw-r----- 1 ftp_coll ict 2324852 Dec 10 00:30 /bmd/boboprd/BOBOBSC25481220071210003007000.intec -rw-r----- 1 ftp_coll ict 2316639 Dec 9 23:23 /bmd/prod/input/ICTBSC36654520071209232300000.intec -rw-r----- 1 ftp_coll ict 2871303 Dec 9 23:38 /bmd/prod/input/ICTBSC36654620071209233800000.intec -rw-r----- 1 ftp_coll ict 1730269 Dec 9 23:53 /bmd/prod/input/ICTBSC36654720071209235301000.intec but i want the output list just one file (the newest one) for each directory i woul be grateful to any help. Thanks |
|
||||
|
A further thought - if you are interested in newest file in a directory but wanteing to recurse also:-
find /BMD -type d -exec ls -lt | head -1 {}\; Only thing is I am not *sure* the pipe will work ok within the -exec construct. |
|
||||
|
ajcannon , The question is to search for files newer than a reference file created with touch. It seems that the created file with touch don't have the expected created date. The touch command is not used properly, it should be: Code:
touch -t [CC]YYMMDDhhmm[ss] filename or: Code:
touch -t [CC]YYMMDDhhmm[ss] filename The century and the seconds are optional. Regards |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|