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. |
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.
|
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 Code:
grep [...] | xargs -l readlink -f |
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.
|
All times are GMT -5. The time now is 03:12 PM. |