Professional Web Applications Themes

what is the command & syntax to search a file on Unix ? - Linux / Unix Administration

Hi I need to search for a file in Unix - what is the actual/full command w/ syntax to do so? It doesn't have windows like explorer or anything else - just command based. Thanks...

  1. #1

    Default what is the command & syntax to search a file on Unix ?

    Hi

    I need to search for a file in Unix - what is the actual/full command w/
    syntax to do so?

    It doesn't have windows like explorer or anything else - just command based.

    Thanks
    MoniqE@msn.com Guest

  2. #2

    Default Re: what is the command & syntax to search a file on Unix ?

    On 2004-10-23, com <com> wrote: 

    Depending on where you expect the file to be, start with ls(1). The
    (1), by the way, means the use of the command is doented in section
    one of the manual, so you can type `man 1 locate' to get an explanation
    of all the options you can use -- if you don't give a number, man(1)
    will guess. If ls(1) doesn't give the expected results, you could try
    locate(1), or if that fails, find(1), which is a bit harder to use and
    is slower, but it has more options and can be more accurate. This list
    isn't exhaustive, but lists just the most general facilities.

     

    Welcome to the world of unix[tm]. For an introduction, you could try this:

    http://www.oreilly.com/catalog/lunix5/


    There do exist various file-browser things for the people that can't
    handle the command line, like midnight commander. It might be installed on
    your system. You could ask your system administrator about it.


    --
    j p d (at) d s b (dot) t u d e l f t (dot) n l .
    jpd Guest

  3. #3

    Default Re: what is the command & syntax to search a file on Unix ?

    com wrote:
     

    find DIR -name NAME -type f -print

    Replace DIR with the directory where you want to start and NAME
    with the name of the file you are looking for.

    Peter

    --
    Peter J. Acklam - no - http://home.online.no/~pjacklam
    Peter Guest

  4. #4

    Default Re: what is the command & syntax to search a file on Unix ?

    On Sat, 23 Oct 2004 13:22:25 -0500, com
    <com> wrote:
     

    man find

    What file are you searching for? What characteristics does it
    have that set it apart from other files?

    If you know the name, or part of it, and it is a regular file
    (not a fifo or directory, etc.) then:

    find /dir -type f -name '*foo*'

    That will search, recursively, the entire directory tree of
    /dir, for files with "foo" in their names.

    find has *many* options/arguments to aid searches.

    You can also have find do operations on the files it finds:

    find /dir -type f -name '*foo*' -exec cat {} \ [/ref]

    That would append a copy of every file found, in order, to
    a newfile in your home directory called "newfile". The
    '{}' represents each file that is found, one at a time.

    The '\' escapes (cancels) the newline so that the shell sees it
    as one line. I did that only so that it would be a command that
    would work as written on the commandline *and* this post would be
    properly formatted. You can just put it all on one line and drop
    the '\'.

    You may also have the 'locate' command (it uses find and keeps
    a database of your current files, which has to be updated
    regularly with a utility called 'updatedb'. Usually this is
    done in the background by a cron job, but you need to make
    sure.

    AC

    Alan Guest

  5. #5

    Default Re: what is the command & syntax to search a file on Unix ?



    com wrote: 

    See if it has "vsh" (Visual SHell) if you want simple explorer-style
    functionality.

    Ed.
     
    Ed Guest

  6. #6

    Default Re: what is the command & syntax to search a file on Unix ?

    com wrote:
     

    To search the whole system, su to root and try;

    find / |grep -i file-name
    Hugh Guest

Similar Threads

  1. Command line Syntax
    By Manish Uskaikar in forum PERL Beginners
    Replies: 3
    Last Post: December 1st, 04:59 PM
  2. Grant Command Syntax
    By Kubaton Lover in forum PHP Development
    Replies: 0
    Last Post: November 4th, 07:58 PM
  3. Replies: 4
    Last Post: September 23rd, 01:53 AM
  4. unix command to delete parts of a file
    By melissa_benkyo in forum Linux / Unix Administration
    Replies: 6
    Last Post: July 9th, 07:22 AM
  5. Unix alias command in script file
    By Christine Leseigneur in forum Mac Applications & Software
    Replies: 1
    Last Post: June 26th, 10:03 AM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139