LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   ls to display path? (https://www.linuxquestions.org/questions/linux-newbie-8/ls-to-display-path-335923/)

benobi 06-21-2005 08:28 PM

ls to display path?
 
How do you get ls to display the path to the file?

For example, lets say I'm looking for a file in one of the million subdirectories in /etc. And I know it's in one of the subdirectories but I don't know which subdirectory and I don't wanna try going through each one.

I type:

ls -R /etc | grep blah

and it just displays all the "blah"s in the subdirectories of /etc, but it doesn't tell me exactly where in /etc the file is. I tried -l flag for long but that didn't help. I couldn't find anything in the man page for ls, but maybe I overlooked an argument?

merchtemeagle 06-21-2005 09:35 PM

Code:

ls -lR /etc | grep blah
or using locate:

Code:

locate blah

benobi 06-22-2005 02:42 AM

I still get the same result with that:

ls -lR /etc | grep fonts.conf

results in:

-rw-r--r-- 1 root root 17186 Apr 19 13:54 fonts.conf

But it doesn't tell me the path to fonts.conf. Based on the information ls gives me, I only know that fonts.conf is in one of the many subdirectories of /etc, but I don't know exactly which of the several subdirectories it is in.

chrism01 06-22-2005 03:08 AM

Use find cmd eg
find . -iname 'somefilepatternhere' -print 2>/dev/null
btw, you'll need the quote marks if using wildcard in 'somefilepatternhere'


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