1752817 Members
4249 Online
108789 Solutions
New Discussion юеВ

Find command

 
SOLVED
Go to solution
Jeffrey W. Stewart
Frequent Advisor

Find command

If I use find . -mtime -5, can I then display the date and time for the files found? I tried

find . -mtime -5 | ll
find . -mtime -5 -exec ll {} \;
find . -mtime -5 | xargs ll
9 REPLIES 9
John Poff
Honored Contributor

Re: Find command

Hi,

I got it to work this way:

find . -mtime 5 | xargs ls -ld


JP
Rodney Hills
Honored Contributor

Re: Find command

Answer- Yes.

Your second example should work, but you may want to put "-d" option on "ll" so that directories don't list content.

find . -mtime -5 -exec ll -d {} \;

HTH

-- Rod Hills
There be dragons...
James R. Ferguson
Acclaimed Contributor
Solution

Re: Find command

Hi Jeffrey:

If it's *files* you want, let 'find' filter that:

# find . -type f -mtime -5 -exec ls -l {} \;

...or less resource intensive because 'exec' spawns a new process for each file found:

# find . -type f -mtime -5|xargs ls -l

Regards!

...JRF...
Steve Steel
Honored Contributor

Re: Find command

Hi

last option using ll -d instead 0f ll

find . -mtime -5 | xargs ll -d

Works fine

find . -mtime -5 |while read $line
do
ll $line|cut -c45-128
done

Is alternative

Play with it

Steve Steel
If you want truly to understand something, try to change it. (Kurt Lewin)
Ricardo Bassoi
Regular Advisor

Re: Find command


Hi,

Is better to use the -type f option ( Regular Files ):

find . -type f -mtime -5 -exec ls -l {} \;

Regards,

Ricardo Bassoi


If you never try, never will work
James Odak
Valued Contributor

Re: Find command

if
find . -mtime -5 -exec ll {} \;

isnt working

try
find . -print -mtime -5 -exec ll {} \;


otherwise you have very good advice from everyone else above


Gary Yu
Super Advisor

Re: Find command

Hi,

how about ll -ld `find . -mtime -5 -print` ?
Jeffrey W. Stewart
Frequent Advisor

Re: Find command

Thanks for everyone's help. The key was "files" and that really helped me with what I was trying to do.
Jeffrey W. Stewart
Frequent Advisor

Re: Find command

Solution is in thread.