LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 06-06-2012, 11:31 AM   #1
kike_coello
Member
 
Registered: Jul 2005
Location: maryland
Distribution: Ubuntu 9.04
Posts: 88

Rep: Reputation: 17
How do you display the full path of a file?


Hi, I just want to know if there is a command to display the full path or address of a file by just typing in the name of the file or piping or redirecting the name of the file to some command.

The way I get the name of the files is with grep, and I get a bunch of files, but they are just filenames with extensions. What I want is to feed this column of filenames to some command and get the full path and the filename.

Or would I have to write a script, but even then I think I would need a command to basically just give me the full path of the file and then I could write a loop for the rest of the files.

Thanks

Enrique

PS: I don't know if this is the right place to post, sorry.
 
Old 06-06-2012, 11:56 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
If (s)locate runs as a (daily) cron job and if it covers all areas you want to find items in then you could type 'locate itemname' or 'locate -r ".*name$";'. (Note as unprivileged user you can have your own locate database: 'man updatedb; man locate' for more.) Else 'find /path/somewhere -iname \*item\*;' will work too.
 
1 members found this post helpful.
Old 06-06-2012, 01:17 PM   #3
antegallya
Member
 
Registered: Jun 2008
Location: Belgium
Distribution: Debian
Posts: 109

Rep: Reputation: 42
Hi,

for the problem of getting the full path of the file, you could use unSpawn solution to find them in the whole system. But if those filenames are actually relative paths, you could use
Code:
readlink -f relative_path
But you can't just pipe paths to readlink. However you can avoid the writing of a loop using xargs like this
Code:
grep [...] | xargs -l readlink -f
It will call 'readlink -f' with each output line of your grep.
 
1 members found this post helpful.
Old 06-06-2012, 02:22 PM   #4
kike_coello
Member
 
Registered: Jul 2005
Location: maryland
Distribution: Ubuntu 9.04
Posts: 88

Original Poster
Rep: Reputation: 17
Thanks, I got the full path with find. I couldn't get readlink to work, sorry. And locate didn't find the files I needed, it found other files with similar names, even after running update. But thanks for the help unSpawn and antegallya.
 
  


Reply


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Configuring GNOME to have Full File Path Text Fields in File Open Dialog Boxes bgoodr Linux - Desktop 3 11-29-2011 09:07 AM
How to get the full path of a file in C? Basel Programming 3 10-30-2010 10:52 PM
Get full path of a file get_to_know Programming 1 08-03-2009 12:34 AM
how can i find full path of file? DoME69 Programming 5 03-04-2009 02:11 PM
full path of a file ttilt Linux - General 1 11-08-2005 06:02 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:50 PM.

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