• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

Unix Find: Question for the experts

Collapse
X
  •  
  • Filter
  • Time
  • Show
Clear All
new posts

    #11
    I missed the points for being too slow but I usually use:

    Code:
    find /home/chubba/ -type f -exec grep -H 'chubba' {} \;
    To find the word 'chubba' in my home folder...

    Comment


      #12
      good work Chubba, points awarded

      from what I can see there are several schools of thought on this finding a string in a file on unix

      good work lads

      Milan.

      Comment


        #13
        Stop

        Milan,

        You really think you should be doing this? Sounds a little like we're pushing out boundaries a bit. .net is far easier in a windows environment.

        Remember, if you don't do it they can always get some permie to take the risk.

        Comment


          #14
          Pondlife,

          less of it.

          I'm doing a hardware migration

          took an offline backup of the existing

          created filesystems and users on the new host

          restored the backup to the new host

          changing the hostname EVERYWHERE to the new hostname and trying to get the system to startup

          Everything's workin' fine apart from one component

          Milan.

          Comment


            #15
            Similar to suggestion above.

            find . | xargs grep <string>

            Comment


              #16
              /home/MilanB

              /home/MilanB

              is a corrupted filesystem. it needs to be rebuilt from scratch and socially reformatted

              Comment


                #17
                Originally posted by Cowboy Bob
                cd <root directory to search from>
                grep "whattofind" `find .`

                Note that is the apostrophe below the escape key on most keyboards.
                You don't have to cd.

                find <directory_to_search_from> -print -name <wildcard> -exec grep <whattofind> {} \;

                where <wildcard> is a pattern of the files you want to search, e.g. *.c (or for that matter fred.c if you only want to check files of that name).

                On some versions of unix the file paths won't be printed unless you use the -print argument, although I think this is usually redundant these days.

                (Needless to say none of the '<' or '>' symbols are redirects in the above.)

                edit: On most unices these days the grep command has a -r option (for 'recursive', i.e. a treewalk a-la find)
                Last edited by OwlHoot; 21 July 2007, 05:05.
                Work in the public sector? Read the IR35 FAQ here

                Comment

                Working...
                X