Linux Command Line Tips and Tricks Text Editing For mostly all examples we use sed utility with substitution command. The syntax is pretty simple: sed -i 's/SEARCH-WORD/REPLACMENT-WORD/gI' input # or for regular expressions: sed -i 's/SEARCH-REGEXP/REPLACMENT-WORD/gi' input The -i option edit and update text file in place. For piped input from another utility it is not necessary The / are delimiters between words or regexp. sed -i 's/SEARCH-REGEXP/REPLACMENT-WORD/gI' - I flag make search case insensitive sed -i 's/SEARCH-REGEXP/REPLACMENT-WORD/gI' - for text files input use g flag to make search global across the whole file print first N chars We want print first N chars. Linux
SED Tutorial - how replace or substitute file contents How replace or substitute text in SED text stream editor Linux Linux Utilities
SED Tutorial - how print or delete particular line How we can print or delete particular line with SED (text) stream editor Linux Linux Utilities