how to search with ls with showing the full path

Posted on 2006-04-25
Last Modified: 2013-12-27

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

Question by:malibusa
    LVL 14

    Accepted Solution


    without writing a script you cannot.

    But by using a different command you can;

    find ./ -name abc -ls

    LVL 6

    Expert Comment

    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 and go to your architecture and platform on the right.
    LVL 38

    Expert Comment

    "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
    LVL 6

    Expert Comment

    An expansion of an earlier comment is:

    to find a file:
    find / -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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    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…
    This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
    Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
    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.

    759 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

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now