Re: sed vs gnu sed

2011-11-10 Thread Vincent Hoffman

On 10/11/2011 07:00, per...@pluto.rain.com wrote:

Vincent Hoffmanvi...@unsane.co.uk  wrote:


bsd sed (correctly according to SUS at least, I believe[1])
appends a newline when writing to standard out, gnu sed doesnt.

The wonderful thing about standards is that there are so many to
choose from  -- Tanenbaum


is there any easy way to make our sed do the same as gnu sed here?

As long as it is OK to remove _all_ newlines -- which seems to be
the case here -- you could pipe the output through tr -d '\012'



Thanks to all for suggestions, I'll move to using tr at some point i 
think but the overhead of any of the approaches is pretty negligable 
(except for firing up python/perl ;)


Vince


___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: sed vs gnu sed

2011-11-10 Thread krad
On 10 November 2011 10:33, Vincent Hoffman vi...@unsane.co.uk wrote:

 On 10/11/2011 07:00, per...@pluto.rain.com wrote:

 Vincent Hoffmanvi...@unsane.co.uk  wrote:

  bsd sed (correctly according to SUS at least, I believe[1])
 appends a newline when writing to standard out, gnu sed doesnt.

 The wonderful thing about standards is that there are so many to
 choose from  -- Tanenbaum

  is there any easy way to make our sed do the same as gnu sed here?

 As long as it is OK to remove _all_ newlines -- which seems to be
 the case here -- you could pipe the output through tr -d '\012'



 Thanks to all for suggestions, I'll move to using tr at some point i think
 but the overhead of any of the approaches is pretty negligable (except for
 firing up python/perl ;)

 Vince


  __**_
 freebsd-questions@freebsd.org mailing list
 http://lists.freebsd.org/**mailman/listinfo/freebsd-**questionshttp://lists.freebsd.org/mailman/listinfo/freebsd-questions
 To unsubscribe, send any mail to freebsd-questions-**
 unsubscr...@freebsd.org freebsd-questions-unsubscr...@freebsd.org


 __**_
 freebsd-questions@freebsd.org mailing list
 http://lists.freebsd.org/**mailman/listinfo/freebsd-**questionshttp://lists.freebsd.org/mailman/listinfo/freebsd-questions
 To unsubscribe, send any mail to freebsd-questions-**
 unsubscr...@freebsd.org freebsd-questions-unsubscr...@freebsd.org



you could sidestep the issue entirely /usr/ports/textproc/gsed
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: sed vs gnu sed

2011-11-09 Thread Matthew Seaman

On 09/11/2011 10:30, Vincent Hoffman wrote:

is there any easy way to make our sed do the same as gnu sed here?
for now I have encapsulated the whole thing in a subshell
[backup@banshee ~]$ echo -n $(echo -n /boot:7:1:5; /:7:1:5;
/var:7:1:5  | sed -n 's/[[:space:]]*;[[:space:]]*/;/gp')
/boot:7:1:5;/:7:1:5;/var:7:1:5[backup@banshee ~]$

Which works but seems a little hackish.


You can do it with awk(1):

# echo -n /boot:7:1:5; /:7:1:5; /var:7:1:5 | \
 awk ' { gsub([[:space:]]*;[[:space:]]*, ;, $0) ; printf %s, $0 }'

Not sure if that's any better than your solution using echo though. 
Also trivial in perl(1) or python(1) or whatever, but it seems a waste 
to fire up a whole perl interpreter just to do that.


Cheers,

Matthew

--
Dr Matthew J Seaman MA, D.Phil.   7 Priory Courtyard
  Flat 3
PGP: http://www.infracaninophile.co.uk/pgpkey Ramsgate
JID: matt...@infracaninophile.co.uk   Kent, CT11 9PW
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: sed vs gnu sed

2011-11-09 Thread Jason Lenthe

On 11/09/11 05:30, Vincent Hoffman wrote:

'Hi all,
 I'm trying to move a script from a linux box to a freebsd box.
All going well as its just a bash script and bash is bash, however there
is one line I'm unable to use directly, as bsd sed (correctly according
to SUS at least, I believe[1]) appends a newline when writing to
standard out, gnu sed doesnt. example
BSD
[backup@banshee ~]$ echo -n /boot:7:1:5; /:7:1:5; /var:7:1:5  | sed -n
's/[[:space:]]*;[[:space:]]*/;/gp'
/boot:7:1:5;/:7:1:5;/var:7:1:5
[backup@banshee ~]$

LINUX

[backup@amber ~]$ echo -n /boot:7:1:5; /:7:1:5; /var:7:1:5  | sed
's/[[:space:]]*;[[:space:]]*/;/g'
/boot:7:1:5;/:7:1:5;/var:7:1:5[backup@amber ~]$

is there any easy way to make our sed do the same as gnu sed here?



You could also just lop off the newline with tr -d '\n':

echo -n /boot:7:1:5; /:7:1:5; /var:7:1:5  | sed -n 
's/[[:space:]]*;[[:space:]]*/;/gp' | tr -d '\n'


___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: sed vs gnu sed

2011-11-09 Thread perryh
Vincent Hoffman vi...@unsane.co.uk wrote:

 bsd sed (correctly according to SUS at least, I believe[1])
 appends a newline when writing to standard out, gnu sed doesnt.

The wonderful thing about standards is that there are so many to
choose from  -- Tanenbaum

 is there any easy way to make our sed do the same as gnu sed here?

As long as it is OK to remove _all_ newlines -- which seems to be
the case here -- you could pipe the output through tr -d '\012'
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org