Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: Command line command

  1. #1
    Join Date
    Dec 2008
    Location
    Montana, USA
    Posts
    550

    Default Command line command

    I'm a little embarrassed to ask this one but, I just can't seem to figure it out.

    I'm looking a way to display the location of a file from the command line. For those familiar with DOS, I want to do a
    Code:
    DIR SOMEFILE /S
    where DIR is a less able version of ls

    I want to be able to go above the level of the file tree from where I know the file resides (root as last resort) and issue the command and see the file name and path, not matter where in the file tree it resides.

    I've tried find and can't get the results I want. I've tried ls and still can't see a file I know is there.

    Dolphin seems to work but I don't get the same rock solid belief in a graphical tool as I do from the command line. In other words, if Dolphin says the file doesn't exist, I don't quite believe it. If I get a file not found from the proper command line command, I know it's not there.

    Bart
    Last edited by montana_suse_user; 21-Apr-2013 at 15:28. Reason: fat fingers

  2. #2
    Join Date
    Mar 2008
    Location
    Oz
    Posts
    11,727
    Blog Entries
    2

    Default Re: Command line command

    Try locate
    Leap 42.3 & 15.1(Beta) &KDE
    FYIs from the days of yore

  3. #3
    Join Date
    Mar 2008
    Location
    Oz
    Posts
    11,727
    Blog Entries
    2

    Default Re: Command line command

    its in findutils-locate and there's an app for KDE called kio-locate that does the same as command line but organises it a bit better
    Leap 42.3 & 15.1(Beta) &KDE
    FYIs from the days of yore

  4. #4
    Join Date
    Feb 2010
    Location
    Germany
    Posts
    4,654

    Default Re: Command line command

    Code:
    find . -name SOMEFILE
    in short find is the command you are looking for.

    --
    PC: oS 12.3 x86_64 | i7-2600@3.40GHz | 16GB | KDE 4.10.0 | GTX 650 Ti
    ThinkPad E320: oS 12.3 x86_64 | i3@2.30GHz | 8GB | KDE 4.10.0 | HD 3000
    HannsBook: oS 12.3 x86_64 | SU4100@1.3GHz | 2GB | KDE 4.10.0 | GMA4500

  5. #5
    Join Date
    Dec 2008
    Location
    Montana, USA
    Posts
    550

    Default Re: Command line command

    Quote Originally Posted by martin_helm View Post
    Code:
    find . -name SOMEFILE
    in short find is the command you are looking for.

    --
    PC: oS 12.3 x86_64 | i7-2600@3.40GHz | 16GB | KDE 4.10.0 | GTX 650 Ti
    ThinkPad E320: oS 12.3 x86_64 | i3@2.30GHz | 8GB | KDE 4.10.0 | HD 3000
    HannsBook: oS 12.3 x86_64 | SU4100@1.3GHz | 2GB | KDE 4.10.0 | GMA4500
    That is indeed what I was looking for. I looked at the man page again and found the -name option. I'm going to have to spend some time with it, it makes references to things that I don't have down and need to know before I understand it. I am still however, confused by the . I'm guessing it refers to the starting place for the find command to start. It seems to be in the wrong place.

    Thanks so much!

    swerdna, after I installed findutils package I now have that command available! Thanks!

  6. #6
    Join Date
    Feb 2010
    Location
    Germany
    Posts
    4,654

    Default Re: Command line command

    The first argument to find is the directory from which to start the
    search, the . is just for the current directory, search is recursive,
    you can of course explicitly specify any other directory in a relative
    or absolute path.

    locate is faster than find, it searches a database (which is
    created/updated with updatedb as root, usually this update runs as a
    chron job once a day for example).

    --
    PC: oS 12.3 x86_64 | i7-2600@3.40GHz | 16GB | KDE 4.10.0 | GTX 650 Ti
    ThinkPad E320: oS 12.3 x86_64 | i3@2.30GHz | 8GB | KDE 4.10.0 | HD 3000
    HannsBook: oS 12.3 x86_64 | SU4100@1.3GHz | 2GB | KDE 4.10.0 | GMA4500

  7. #7
    Join Date
    Dec 2008
    Location
    Montana, USA
    Posts
    550

    Default Re: Command line command

    Quote Originally Posted by martin_helm View Post
    The first argument to find is the directory from which to start the
    search, the . is just for the current directory, search is recursive,
    you can of course explicitly specify any other directory in a relative
    or absolute path.
    So, it is as I thought.

    locate is faster than find, it searches a database (which is
    created/updated with updatedb as root, usually this update runs as a
    chron job once a day for example).
    Ah! Then the find command is exactly what I wanted. It depends on nothing other than the fact that the file exists. Great!

    Again, Thanks!

    Bart

  8. #8
    Join Date
    Feb 2009
    Location
    Spain
    Posts
    25,547

    Default Re: Command line command

    On 2013-04-22 01:16, Martin Helm wrote:
    > locate is faster than find, it searches a database (which is
    > created/updated with updatedb as root, usually this update runs as a
    > chron job once a day for example).


    Not as root, but as 'nobody', which is a user in the system.

    It is configured in the file "/etc/sysconfig/locate". You can select
    there the user it runs under, and what directories it does not search.
    And a few more things.

    --
    Cheers / Saludos,

    Carlos E. R.
    (from 12.1 x86_64 "Asparagus" at Telcontar)

  9. #9
    Join Date
    Feb 2009
    Location
    Spain
    Posts
    25,547

    Default Re: Command line command

    On 2013-04-22 01:46, montana suse user wrote:

    >> locate is faster than find, it searches a database (which is
    >> created/updated with updatedb as root, usually this update runs as a
    >> chron job once a day for example).

    >
    > Ah! Then the find command is exactly what I wanted. It depends on
    > nothing other than the fact that the file exists. Great!


    It makes sense to use 'locate' first, because if the file existed
    yesterday, it finds it immediately. If you use the option "-e", it also
    verifies that the file is still there.

    Then, if locate fails, use find, which can take a long time to complete,
    depending on how big is the space you tell it to search.

    --
    Cheers / Saludos,

    Carlos E. R.
    (from 12.1 x86_64 "Asparagus" at Telcontar)

  10. #10
    Join Date
    Aug 2010
    Location
    Chicago suburbs
    Posts
    12,631
    Blog Entries
    3

    Default Re: Command line command

    Quote Originally Posted by robin_listas View Post
    It makes sense to use 'locate' first, because ...
    I don't think "locate" is installed by default. It is not on my system, and I never de-selected nor uninstalled it.
    openSUSE Leap 15.1; KDE Plasma 5;
    testing Leap 15.2Alpha

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •