0
sed -n 's/^@(#)*/    /p'

The input is piped in for this sed command. However, I am having tough times understanding this expresion 's/^@(#)*/ /p'

NeronLeVelu
  • 9,908
  • 1
  • 23
  • 43
Sahil
  • 359
  • 2
  • 5
  • 13
  • Matches `@(#` followed by 0 or more `)` at the start of the line, and replaces them with 4 spaces. – 123 Sep 22 '15 at 10:11

1 Answers1

1

If the line starts with the string formed by the contiguous characters @ ( and # followed by the charter ) repeated zero or more times, then that line is printed after the aforementioned string is replaced with 4 blank chars. All other lines are not printed:

$ cat file
X@(#)*1
@(#))))2
@(#)*3
@(#)4
@(#5
@(6

$ sed -n 's/^@(#)*/    /p' file
    2
    *3
    4
    5
Ed Morton
  • 188,023
  • 17
  • 78
  • 185