Advertisement
dsuveges

gyk_grep script

Nov 1st, 2016
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.46 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Checking file if it was given:
  4. if [ -z ${1} ]; then echo "File was not given!"; exit 1; fi
  5. if [ ! -f ${1} ]; then echo "File (${1}) could not be opened!"; exit 1; fi
  6.  
  7. # So at this point we know we have a valid file to search in.
  8.  
  9. # Reading pattern from standard input:
  10. echo "Add meg a honapot"
  11. read i
  12. if [ -z ${i} ]; then echo "Pattern was not submitted."; exit 1; fi
  13.  
  14. # If both the file and the pattern are given, let's grep:
  15. grep  -iw ${i} ${1}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement