Find the answer to your Linux question:
Results 1 to 4 of 4
I am trying to write a script that will display the following words: kill, bomb, Joe Smith, quit and steal. I need the script to report to the screen the ...
  1. #1
    Just Joined!
    Join Date
    Jan 2011
    Posts
    87

    Trouble with a bash script that finds offensive words

    I am trying to write a script that will display the following words: kill, bomb, Joe Smith, quit and steal. I need the script to report to the screen the offenders username, the line with the bad word found, and path and file name. This is what I have so far:

    Code:
    while read -rd '' file; do 
    badfiles+=("$file"); done < <(find /home -type f -exec grep -qE 'kill|bomb|Joe Smith|quit|steal' {} \; -print0)
    I thought that this code would report to the screen everything that I need, but it does not. How do I get the script to report to the screen?

  2. #2
    Linux Newbie
    Join Date
    Dec 2009
    Posts
    241
    Have you tried:
    Code:
    while read -rd '' file; do 
    echo $file
    done < <(find /home -type f -exec grep -qE 'kill|bomb|Joe Smith|quit|steal' {} \; -print0)

  3. #3
    Just Joined!
    Join Date
    Jan 2011
    Posts
    87
    Quote Originally Posted by zombykillah View Post
    Have you tried:
    Code:
    while read -rd '' file; do 
    echo $file
    done < <(find /home -type f -exec grep -qE 'kill|bomb|Joe Smith|quit|steal' {} \; -print0)
    that still does not report anything. Do I still have something wrong in the code itself?

  4. #4
    Linux Newbie
    Join Date
    Dec 2009
    Posts
    241
    Kill the options of the read command.

    just:
    Code:
    while read file; do 
    echo $file
    done < <(find /home -type f -exec grep -qE 'kill|bomb|Joe Smith|quit|steal' {} \; -print0)

Posting Permissions

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