Home > database >  What does the option -nr mean in sed?
What does the option -nr mean in sed?

Time:11-29

I am trying out the sed command and I came across this strange option "-nr", I am using the sed command with this alias:

alias 20='printf "d\n" {1..20}'

The two commands have the same output, but I'm not sure if they're the same, the manual doesn't contain this option.

20 | sed -nr '5,$p'
20 | sed -n '5,$p'

Both return:

005
006
007
008
009
010
011
012
013
014
015
016
017
018
019
020

CodePudding user response:

From man sed:

-E Interpret regular expressions as extended (modern) regular expressions rather than basic regular expressions (BRE's)

-r Same as -E for compatibility with GNU sed.

I'm using gsed in MacOS and get the output. Which is correct!

  • Related