Find the answer to your Linux question:
Results 1 to 3 of 3
Hi people. I want to create a batch that could find a specific words inside email files, my script need something extra. This is the main part, but is not ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Nov 2009
    Posts
    7

    Question Doubts with find and grep?


    Hi people.

    I want to create a batch that could find a specific words inside email files, my script need something extra.

    This is the main part, but is not giving me what I need:

    Code:
    echo -e "Username: \c"
    read name
    
       if [ -d /home/$name ]; then
    
            find /home/$name/Maildir  -exec grep -H -w "attachment" {} \; > /home/buffer/$name.txt
    
       fi
    That output give to me:

    file path+found string

    I need just the /path/filename and forget the found string.

    Someone has a idea how to make this possible, do I need to use other commands?

    Any tip will be appreciated, thanks!!!

    P.S. Centos 5.5.

  2. #2
    Linux Newbie
    Join Date
    Mar 2009
    Posts
    228
    From man grep:

    Code:
    -l, --files-with-matches
    	      Suppress normal output; instead print the	 name  of  each	 input
    	      file  from  which	 output would normally have been printed.  The
    	      scanning will stop on the first match.

  3. #3
    Just Joined!
    Join Date
    Nov 2009
    Posts
    7

    Thumbs up

    lomcevak thanks, that was the trick

Posting Permissions

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