Advertisement
metalx1000

Remove Numbers on Lines that don't match strings

Mar 20th, 2016
625
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.32 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. if [ $# -lt 1 ]
  4. then
  5.   echo "Usage: $0 <file_name>"
  6.   echo "Example: $0 file.txt"
  7.   exit
  8. fi
  9.  
  10. cat $1|while read line
  11. do
  12.   l="$(echo $line|tr '[:upper:]' '[:lower:]')"
  13.   if [[ $l == *"hello"* ]] || [[ $l == *"brother"* ]]
  14.   then
  15.     echo "$line"
  16.   else
  17.     echo "$line"|sed 's/[0-9]/X/g'
  18.   fi
  19. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement