NB: A slightly updated version of this story can be found at my personal github page.


Liked much.


Koroutines.


Multiple commands with -e

$ echo abcde | sed -e 's/a/1/' -e 's/b/2/'
12cde

Grep with -n p

$ sed -n '/TestBasicRowFixture/p' < input.file

Range limit

  • line number e.g. 1,10
  • /Pattern/
  • $ for the end of the file

Stop processing with q

cat large.file | sed '/PATTERN/ q'

Print line number with =

cat large.file | sed -e '/PATTERN/ =' -e '/PATTERN/ q'

Capture groups default mode need escaping

$ echo abcde | sed 's/\([a-z]\)/-&-/'
-a-bcde
$ echo abcde | sed -E 's/([a-z])/-&-/'
-a-bcde

Mykola Gurov

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store