Advertisement
Guest User

Untitled

a guest
Jan 18th, 2020
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. read -p "Enter string to search for in the content of all files in current directory: " target
  2. count=0
  3.  
  4. for entry in *
  5. do
  6. if [ -d "$entry" ]
  7. then
  8. echo "$entry is a directory, skipping..."
  9. elif grep -qF "$target" "$entry"
  10. then
  11. echo "File $entry: contains the string $target!"
  12. ((count++))
  13. fi
  14. done
  15.  
  16. if [ $count -eq 0 ]
  17. then
  18. echo "$target not found in current directory"
  19. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement