Operating System - HP-UX
1834370 Members
1990 Online
110066 Solutions
New Discussion

Re: ls -R output with full pathname

 
SOLVED
Go to solution
Michael Bluemm
Frequent Advisor

ls -R output with full pathname

Hi all,
I want to find some files with a special string recursively by "ls".
For example: ls -lR /usr |grep "May 31"

Output should be something like:
-rw-rw-rw- root sys 124 May 31 12:26 /usr/test
-rw-r--r-- tom users 278 May 31 2002 /usr/users/tom/.login
-rw-r--r-- peter users 1256 May 31 2004 /usr/users2/peter/mist

Any ideas?
Thank you all, Michael
... still trying ...
7 REPLIES 7
Robert-Jan Goossens_1
Honored Contributor

Re: ls -R output with full pathname

How about,

# find /dir -exec ll {} \; | grep "May 31"

Robert-Jan
Patrick Wallek
Honored Contributor

Re: ls -R output with full pathname

That's not how ls works. I don't think that is going to be possible with ls.

Your best bet, as mentioned above, would be to use find or some other method.
Paul_481
Respected Contributor

Re: ls -R output with full pathname

Hi Michael,

Use find instead. redirect it into a file then filter it with grep.

#find . -type f -exec ll {} \; >> /path/outputfile|grep "May 31"


Regards,
Paul
H.Merijn Brand (procura
Honored Contributor
Solution

Re: ls -R output with full pathname

AIcks!

# find /dir -exec ls -ld {} \; | grep "May 31"

ll will list the directory content instead of the directory. You need the -d

Enjoy, Have FUN! H.Merijn [ who would do it in perl ]
Enjoy, Have FUN! H.Merijn
Paul_481
Respected Contributor

Re: ls -R output with full pathname


Hmm, Robert has a better answer.

you cannot do that in ls, "find" is your best shot.

Regards,
Paul
harry d brown jr
Honored Contributor

Re: ls -R output with full pathname

Try the attached perl script.

usage:

./findfile.pl -mtime / | grep " 20050531\."

live free or die
harry d brown jr
Live Free or Die
Michael Bluemm
Frequent Advisor

Re: ls -R output with full pathname

Thank you for your very fast answers,
Procura's was perfect; Paul's was very good too, but did only look for files; Robert's found all, but put some lines twice; Harry: I didn't try the perl-script, because "mtime" was not what I was looking for.
Nice weekend,
Michael
... still trying ...