Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 06-21-2005, 07:28 PM   #1
LQ Newbie
Registered: May 2004
Posts: 18

Rep: Reputation: 0
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?
Old 06-21-2005, 08:35 PM   #2
Registered: Oct 2004
Location: Belgium
Distribution: Slackware 13.37
Posts: 512

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

locate blah
Old 06-22-2005, 01:42 AM   #3
LQ Newbie
Registered: May 2004
Posts: 18

Original Poster
Rep: Reputation: 0
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.
Old 06-22-2005, 02:08 AM   #4
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.10, Centos 7.3
Posts: 17,548

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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Image Path reference in Linux (Absolute path) javabuddy Linux - General 7 06-05-2006 07:45 AM
Apache path and kde path questions darkraider Debian 1 11-12-2005 05:07 AM
System envoirment (for exampe DISPLAY, PATH) originated from which file in linux ? stewchcken Linux - General 1 08-07-2005 12:46 PM
Removing path form PATH maginotjr Linux - Newbie 3 02-12-2005 02:23 PM
How to Chnage Python's module search path (sys.path)? lramos85 Linux - Software 1 05-02-2004 06:10 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:31 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration