SED : Stream Editor

/s - Substitute

/g - Global( consider all in file)

^ - Beginning of the line

$ - End of the line

-i - Make changes to the original file

[0-9]

& - Takes the match as input

[0-9][0-9]* - [Checks both as OR condition]

sed 's/^a/A/g [Replace 'a' in the beginning of every line to 'A']

  • sed '/s/[0-9]/*/g [Replace all numbers to '*']

  • sed 's/[a-z]/*/g' file.txt [Replace all lowercase letters to '*']

  • sed 's/[A-z]/*/g' file.txt [Replace all letters to '*']

  • sed 's/[a-z][A-Z]/*/g file.txt [Replace all lowercase followed by uppercase letters to '*']

  • sed 's/[A-z0-9]/*/g' file.txt [Replace all characters and numbers to '*']

    OR

  • sed 's/[0-z]/*/g' file.txt [Replace all characters and numbers to '*']

    sed 's/[1]/&)&/g -[Looks for numbers, and replaces with '1)1'']

Last updated