?
Solved

how to search with ls with showing the full path

Posted on 2006-04-25
4
Medium Priority
?
7,451 Views
Last Modified: 2013-12-27
dear,

i am trying to search using
ls -R -l | grep abc

but the first found file, does not come with the path,
how could a get the results with the full path

0
Comment
Question by:malibusa
4 Comments
 
LVL 14

Accepted Solution

by:
arthurjb earned 500 total points
ID: 16536492

without writing a script you cannot.

But by using a different command you can;

find ./ -name abc -ls

0
 
LVL 6

Expert Comment

by:durindil
ID: 16537220
You can use the "locate" command.  It is part of the findutils GNU package.  Then, instead of doing:

ls -l |grep abc

You can do:

ls -l `locate abc'

This is a separate package and is not normally installed by default.  You can get this package from http://www.sunfreeware.com/ and go to your architecture and platform on the right.
0
 
LVL 38

Expert Comment

by:yuzh
ID: 16540156
"find" command is the right tool for the job. you can do:

    find `pwd` -name "abc*"

for file only:
    find `pwd` -type f -name "abc*"

man find
to learn more details
0
 
LVL 6

Expert Comment

by:bpeterse
ID: 16546133
An expansion of an earlier comment is:

to find a file:
find / -name 'file.name' -type f  -exec ls -la {} \;

to find a dir:
find / -name 'dirname' -type d  -exec ls -la {} \;

will list the directory as well as the contents.

man find - but it's a long read and takes some practice.  glocate is a good tool as well, found on http://Sunfreeware.com
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
A metadevice consists of one or more devices (slices). It can be expanded by adding slices. Then, it can be grown to fill a larger space while the file system is in use. However, not all UNIX file systems (UFS) can be expanded this way. The conca…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Suggested Courses
Course of the Month15 days, 9 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question