LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices

Reply
 
Search this Thread
Old 04-03-2004, 04:42 PM   #1
stabu
Member
 
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


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

Rep: Reputation: 32
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
 
Old 04-03-2004, 05:34 PM   #3
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

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


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 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 12:41 PM
Listing Used Ports BorgKiller Linux - Security 2 04-13-2005 11:44 PM
Listing Commands Blackout_08 Fedora 2 03-07-2005 09:57 AM
listing users... spotass Linux - Newbie 1 06-12-2004 02:18 AM
long listing using ls -l command display year or time of the file mnd_world Linux - Newbie 1 05-20-2004 11:39 AM


All times are GMT -5. The time now is 05:09 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration