Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
URL Rewriter Bot
URL Rewriter Bot

The answer with the :a label ...

How can I replace each newline (\n) with a space using sed?How can I replace each newline (\n) with a space using sed?

... does not work in freebsd 7.2 on the command line:

 ( echo foo ; echo bar ) | sed ':a;N;$!ba;s/\n/ /g' sed: 1: ":a;N;$!ba;s/\n/ /g": unused label 'a;N;$!ba;s/\n/ /g' foo bar 

But does if you put the sed script in a file or use -e to "build" the sed script...

 > (echo foo; echo bar) | sed -e :a -e N -e '$!ba' -e 's/\n/ /g' foo bar 

or ...

> cat > x.sed << eof :a N $!ba s/\n/ /g eof > (echo foo; echo bar) | sed -f x.sed foo bar 

Maybe the sed in OS X is similar.

The answer with the :a label ...

How can I replace each newline (\n) with a space using sed?

... does not work in freebsd 7.2 on the command line:

 ( echo foo ; echo bar ) | sed ':a;N;$!ba;s/\n/ /g' sed: 1: ":a;N;$!ba;s/\n/ /g": unused label 'a;N;$!ba;s/\n/ /g' foo bar 

But does if you put the sed script in a file or use -e to "build" the sed script...

 > (echo foo; echo bar) | sed -e :a -e N -e '$!ba' -e 's/\n/ /g' foo bar 

or ...

> cat > x.sed << eof :a N $!ba s/\n/ /g eof > (echo foo; echo bar) | sed -f x.sed foo bar 

Maybe the sed in OS X is similar.

The answer with the :a label ...

How can I replace each newline (\n) with a space using sed?

... does not work in freebsd 7.2 on the command line:

 ( echo foo ; echo bar ) | sed ':a;N;$!ba;s/\n/ /g' sed: 1: ":a;N;$!ba;s/\n/ /g": unused label 'a;N;$!ba;s/\n/ /g' foo bar 

But does if you put the sed script in a file or use -e to "build" the sed script...

 > (echo foo; echo bar) | sed -e :a -e N -e '$!ba' -e 's/\n/ /g' foo bar 

or ...

> cat > x.sed << eof :a N $!ba s/\n/ /g eof > (echo foo; echo bar) | sed -f x.sed foo bar 

Maybe the sed in OS X is similar.

:a is a label (as pointed out in comments to that answer)
Source Link
Juan
  • 1.4k
  • 1
  • 12
  • 30

The answer with the :a registerlabel ...

How can I replace each newline (\n) with a space using sed?

... does not work in freebsd 7.2 on the command line:

 ( echo foo ; echo bar ) | sed ':a;N;$!ba;s/\n/ /g' sed: 1: ":a;N;$!ba;s/\n/ /g": unused label 'a;N;$!ba;s/\n/ /g' foo bar 

But does if you put the sed script in a file or use -e to "build" the sed script...

 > (echo foo; echo bar) | sed -e :a -e N -e '$!ba' -e 's/\n/ /g' foo bar 

or ...

> cat > x.sed << eof :a N $!ba s/\n/ /g eof > (echo foo; echo bar) | sed -f x.sed foo bar 

Maybe the sed in OS X is similar.

The answer with the :a register ...

How can I replace each newline (\n) with a space using sed?

... does not work in freebsd 7.2 on the command line:

 ( echo foo ; echo bar ) | sed ':a;N;$!ba;s/\n/ /g' sed: 1: ":a;N;$!ba;s/\n/ /g": unused label 'a;N;$!ba;s/\n/ /g' foo bar 

But does if you put the sed script in a file or use -e to "build" the sed script...

 > (echo foo; echo bar) | sed -e :a -e N -e '$!ba' -e 's/\n/ /g' foo bar 

or ...

> cat > x.sed << eof :a N $!ba s/\n/ /g eof > (echo foo; echo bar) | sed -f x.sed foo bar 

Maybe the sed in OS X is similar.

The answer with the :a label ...

How can I replace each newline (\n) with a space using sed?

... does not work in freebsd 7.2 on the command line:

 ( echo foo ; echo bar ) | sed ':a;N;$!ba;s/\n/ /g' sed: 1: ":a;N;$!ba;s/\n/ /g": unused label 'a;N;$!ba;s/\n/ /g' foo bar 

But does if you put the sed script in a file or use -e to "build" the sed script...

 > (echo foo; echo bar) | sed -e :a -e N -e '$!ba' -e 's/\n/ /g' foo bar 

or ...

> cat > x.sed << eof :a N $!ba s/\n/ /g eof > (echo foo; echo bar) | sed -f x.sed foo bar 

Maybe the sed in OS X is similar.

not sure why <pre> ... </pre> around the last chunk doesn't work, try 4 spaces instead and live with the bogus coloring
Source Link
Juan
  • 1.4k
  • 1
  • 12
  • 30

The answer with the :a register ...

How can I replace each newline (\n) with a space using sed?

... does not work in freebsd 7.2 on the command line:

 ( echo foo ; echo bar ) | sed ':a;N;$!ba;s/\n/ /g' sed: 1: ":a;N;$!ba;s/\n/ /g": unused label 'a;N;$!ba;s/\n/ /g' foo bar 

But does if you put the sed script in a file or use -e to "build" the sed script...

 > (echo foo; echo bar) | sed -e :a -e N -e '$!ba' -e 's/\n/ /g' foo bar 

or ...

 > cat > x.sed (echo foo; echo bar) | sed -f x.sed foo bar > cat > x.sed << eof :a N $!ba s/\n/ /g eof > (echo foo; echo bar) | sed -f x.sed foo bar 

Maybe the sed in OS X is similar.

The answer with the :a register ...

How can I replace each newline (\n) with a space using sed?

... does not work in freebsd 7.2 on the command line:

 ( echo foo ; echo bar ) | sed ':a;N;$!ba;s/\n/ /g' sed: 1: ":a;N;$!ba;s/\n/ /g": unused label 'a;N;$!ba;s/\n/ /g' foo bar 

But does if you put the sed script in a file or use -e to "build" the sed script...

 > (echo foo; echo bar) | sed -e :a -e N -e '$!ba' -e 's/\n/ /g' foo bar 

or ...

 > cat > x.sed (echo foo; echo bar) | sed -f x.sed foo bar 

Maybe the sed in OS X is similar.

The answer with the :a register ...

How can I replace each newline (\n) with a space using sed?

... does not work in freebsd 7.2 on the command line:

 ( echo foo ; echo bar ) | sed ':a;N;$!ba;s/\n/ /g' sed: 1: ":a;N;$!ba;s/\n/ /g": unused label 'a;N;$!ba;s/\n/ /g' foo bar 

But does if you put the sed script in a file or use -e to "build" the sed script...

 > (echo foo; echo bar) | sed -e :a -e N -e '$!ba' -e 's/\n/ /g' foo bar 

or ...

> cat > x.sed << eof :a N $!ba s/\n/ /g eof > (echo foo; echo bar) | sed -f x.sed foo bar 

Maybe the sed in OS X is similar.

Source Link
Juan
  • 1.4k
  • 1
  • 12
  • 30
Loading