Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 13
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    How to find files


    How do I find the path to file that I know is buried somewhere in memory?
    Can wild cards be used? How?

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    14,009
    I assume you mean in disc memory? Use the "find" command. There are two arguments that are relevant. One is for case-sensitive searches, and the other is for case-insensitive searches. Both can take wild-cards: Examples:

    1. Case sensitive: find <dirname> -name 'XYZZY.txt'
    2. Case insensitive: find <dirname> -iname 'xyzzy.txt'

    With wild cards:

    1. find <dirname> -name 'XYZZY.*'
    2. find <dirname> -iname 'xyzzy.*'

    Anyway, read the manpage for the find command as there are a lot of options that can help you out.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  3. #3

    finding files

    You are assuming that the directory is known.
    I wish to look for a file and I don't know where it is.

  4. $spacer_open
    $spacer_close
  5. #4
    For example I enter:
    find name axis
    response is:
    No such file or directory
    I know it exists and would expect a response such as:
    /usr/bin/axis

  6. #5
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    14,009
    Simple: use / for the directory, and use the -L "follow symbolic links" option so directories that may physically reside on another disc or file system can also be covered. If you only have one main file system then you can eliminate the use of the -L option.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  7. #6
    Why can't you give me an example of what you just said. such as:
    name -L /axis

    I just tried that and it doesn't work

    I get:
    bash: name: command not found

  8. #7
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,931
    He could and he did, but then again: You could also read what was written instead of waiting for a copy&paste solution.

    There is this example
    1. find <dirname> -name 'XYZZY.*'
    2. find <dirname> -iname 'xyzzy.*'
    And then he suggested to use / as directory.

    Now guess what the command looks like.
    You must always face the curtain with a bow.

  9. #8
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    14,009
    Read the man page for details. FWIW, the -L option has to go before the starting directory name. The output of the find command is the full path of the matched files. Then you can pipe that output through grep to find the ones that are at the start of '/axis' as in 'startdir/.../axis/filename'
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  10. #9
    I am having difficulty understanding the man page.
    Also I'm not being clear in my goal.
    Here is what I desire to do;
    I am trying to find the path to all the files in the hard drive that have the sequence of letters or numbers or symbols such as for example: axis_45

    I am in this directory:
    jack@debian:~$
    This my home directory or must I get to the root directory to do the search?

    What would be the command to produce an output such as for example:
    /bin/cat/axis_45
    /bin/cp/axis_45
    /usr/bin/axis_45

    This would tell me that axis_45 resides in three different places and gives me the path to it.

  11. #10
    assuming you need to find a file that is named EXACTLY jensor4.txt:
    Code:
    sudo find / -name jensor4.txt
    assuming you need to find a file that has the string 'jensor' in its name, and you don't know whether there are capital letters:
    Code:
    sudo find / -iname '*jensor*'
    you're welcome.

    PS:
    you'll need the sudo because otherwise find will throw LOADS of permission denied errors.
    alternatively, you can also use:
    Code:
    find / -name jensor4.txt 2>/dev/null
    find / -iname '*jensor*' 2>/dev/null
    I am not a "Linux Guru"! Get off me! The Forum software won't let me change it!
    How to ask smart questions | Don't be a Help Vampire
    You can post a link by removing "http://www." from it.

Posting Permissions

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