1

Im trying to use the gsed -n '1~4p' command to only print that line which appears every 8 lines, but apparently it can only be done with a GNU sed, but It doesn't seem that I have one, How would I obtain this?

I have been using sed -n '1,${p;n;n;n;}' , Im not sure if it does the same thing but it doesnt perform print my expected output.

Thanks!

I AM L
  • 241
  • 1
  • 4
  • 11
  • Does the default `sed` included in Solaris work, or is that special syntax only available in GNU sed? – Zhehao Mao Jun 30 '11 at 00:16
  • Yes it is, but for some reason in order to execute this command **'1~4p'** It requires gsed as in GNU sed – I AM L Jun 30 '11 at 00:21
  • There are examples here: http://sed.sourceforge.net/sed1line.txt – I AM L Jun 30 '11 at 00:24
  • Actually I found the solution that **sed -n '1,${p;n;n;n;}'** is the exact same command as the **gsed -n '1~4p'** But Still I need to know how I can use the **gsed** command in SOlaris – I AM L Jun 30 '11 at 00:32

1 Answers1

1

Download and install a version of GNU sed for whichever Solaris version you use.

Source you can build and install is available from ftp://ftp.gnu.org/gnu/sed and depending on the Solaris release you use, prebuilt binary packages may be available with the OS, from the online package repository (for OpenSolaris or Solaris 11), or from a open source packager for older Solaris releases, such as OpenCSW, BlastWave or Sun FreeWare.

alanc
  • 4,102
  • 21
  • 24