LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   help with long listing + locate (https://www.linuxquestions.org/questions/linux-newbie-8/help-with-long-listing-locate-165835/)

stabu 04-03-2004 04:42 PM

help with long listing + locate
 
Hi
The time has come for me to unleash the power of piping on the command-line. Can any one help me with the following:
I use "locate" to find a file, but I also want full details of the file, i.e. a long listing.
As it stands locate only gives me its path.
So, I reckon a pipe is in order. I tried


ls -l < locate {filename}
locate {filename} | ls -l

However none of these worked. Anybody out there quick on the command line draw?

avarus 04-03-2004 05:11 PM

Not very quick on the draw, but here is the answer:

You need to unleash the power of 'xargs'. Try this:

locate porn.jpg | xargs ls -l

TIM

jschiwal 04-03-2004 05:34 PM

You might want to use the -r (--regexp=) option to locate, because it will find any file in the database that contains the string. The example below will only locate the exact match between the last '/' and the end of the line.

locate -r '^.*/<filename>$'


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