LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   searching a file in subdirectories with ls (https://www.linuxquestions.org/questions/linux-newbie-8/searching-a-file-in-subdirectories-with-ls-721031/)

visitnag 04-22-2009 07:47 PM

searching a file in subdirectories with ls
 
I want to search a file in subdirectories with the command ls -ltr..

i gave the command like ls -ltr filename/* but it did not give any results. What must be the error..

billymayday 04-22-2009 07:52 PM

That's trying to do an ls on a directory in the current directory called filename.

Are you trying to find a file called filename?

If so, try "find ./ -type f -name filename"

visitnag 04-22-2009 08:50 PM

I can do it with find...but somewhere i saw listing required files in subdirectories with ls command...but i failed to recollect that command....

billymayday 04-22-2009 08:55 PM

Maybe you meant ls -lRt rather than ls -lrt

visitnag 04-23-2009 11:45 AM

Nope!! nope!!!

I got it.... if you have some 20 subdirectories under user directory and you know that file1 is created in some of these 20 directories, but you dont know who created... To find this file general methods are...
1 using find command
2 using locate command after updating db

But the simple one is ..... go to the user directory... and type
ls -ltr */file1
this will search all the 20 directories and get the file....

if you have some more subdirectories under 20 directories and the file1 is in these directories..

then type

ls -ltr */*/file1 and so on...


All times are GMT -5. The time now is 08:57 PM.