Help answer threads with 0 replies.
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 04-03-2004, 05:42 PM   #1
Registered: Mar 2004
Location: dublin IRL
Distribution: Slackv12.1, Slamd64v12.1,Xubuntu v8.10_64, FC8_64
Posts: 438
Blog Entries: 5

Rep: Reputation: 32
help with long listing + locate

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?
Old 04-03-2004, 06:11 PM   #2
Registered: Apr 2004
Location: Oxford, UK
Distribution: Ubuntu, Debian, various
Posts: 230
Blog Entries: 5

Rep: Reputation: 33
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

Old 04-03-2004, 06:34 PM   #3
LQ Guru
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 677Reputation: 677Reputation: 677Reputation: 677Reputation: 677Reputation: 677
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>$'


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
printf unsigned long long int? blackzone Programming 9 03-04-2008 01:41 PM
Listing Used Ports BorgKiller Linux - Security 2 04-14-2005 12:44 AM
Listing Commands Blackout_08 Fedora 2 03-07-2005 10:57 AM
listing users... spotass Linux - Newbie 1 06-12-2004 03:18 AM
long listing using ls -l command display year or time of the file mnd_world Linux - Newbie 1 05-20-2004 12:39 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:19 AM.

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