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

    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:

    echo -e "Username: \c"
    read name
       if [ -d /home/$name ]; then
            find /home/$name/Maildir  -exec grep -H -w "attachment" {} \; > /home/buffer/$name.txt
    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
    From man grep:

    -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

    Thumbs up

    lomcevak thanks, that was the trick

  4. $spacer_open

Posting Permissions

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