sed command and slang replacer

  • Sed is a stream editor. A stream editor is used to perform basic text transformations on an input stream (a file or input from a pipeline).
  • sed command is used to replace text.
  • Example: Create file in which replace words are defined like
s/gne/Guru Nanak Dev Engineering College/g
s/gr8/great/g
s/yrs /years /g
s/yr /year /g
s/C /see /g
s/U /you /g
  • Create text file shortHand.txt written text like
I C U at gne, which is gr8 college. gne is 56 yr old. U need to C me  at that gr8 college, called gne.
  • Now, run the following command:
sed -f sedData shortHand.txt > longHand.txt
  • This command output the longHand.txt file in which all words written in shorthand are replace with longhand words.
I see you at Guru Nanak Dev Engineering College, which is great college. Guru Nanak Dev Engineering College is 56 year old. you need to see me
at that great college, called Guru Nanak Dev Engineering College.
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a comment