Results 1 to 3 of 3

Thread: [SOLVED] shell script that searches /home for a file

  1. #1
    Join Date
    Oct 2007
    Beans
    832
    Distro
    Ubuntu 9.04 Jaunty Jackalope

    [SOLVED] shell script that searches /home for a file

    Hello,

    Can someone pls help me with a problem?

    I'd like to find the code needed to search an ENTIRE /home directory for a file.

    I'm not sure what I have is written correctly, but it does work; it just won't do everything I want.

    Here's what I have:

    find /home/$USER/some_file.txt -print | while read obj

    I'm only showing one line of this code just to keep this msg short.

    However, it only searches the $USER directory and not all the other folders within. I want to make it search all the directories within the $USER.

    Can someone write an example of how it should be?

    Thank you in advance..

  2. #2
    Join Date
    Aug 2005
    Beans
    10
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: shell script that searches /home for a file

    I tried find on my machine it appears to recurse during the search without any command line switches. So, you could try something like this:

    find /home/* -name "*somefile*"

    if you have a list of users dirs you want to search, instead of all of them, you could try:

    for i in `john ringo paul george`; do echo $i; find /home/$i -name "*somefile*"; done

  3. #3
    Join Date
    Oct 2007
    Beans
    832
    Distro
    Ubuntu 9.04 Jaunty Jackalope

    Re: [SOLVED] shell script that searches /home for a file

    enatiello,

    thank you for this. Perfect answer and it worked.

    Geez! I thought it was something completely different.

    take care...

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
  •