1849284 Members
5945 Online
104042 Solutions
New Discussion

sed question

 
SOLVED
Go to solution

sed question

Hi experts,

Could someone please explain precisely what the following sed one line is doing :

bdf | sed '/:/N^J{^Js%\n% %^J}'

Thanks in advance and points will be given
7 REPLIES 7
Pete Randall
Outstanding Contributor

Re: sed question

Not much:

# bdf | sed '/:/N^J{^Js%\n% %^J}'
sed: Function /:/N^J{^Js%\n% %^J} cannot be parsed.


Pete

Pete
Sandman!
Honored Contributor

Re: sed question

It will join two adjacnt lines together. The "N" gets the next line of input and "s%\n% %" command replace the embedded newline with a space. I am not sure what "/:/" is doing. Is it giving an error on your machine?

~cheers

Re: sed question

Thanks for the info, basically it currently does not work on our system, the end user is trying to prevent bdf output utilising 2 lines of output per file system.

One thought I had was to use bdfmegs ....

I'll know more on Monday.
Tim Nelson
Honored Contributor
Solution

Re: sed question

How about this instead.

bdf -l |awk '{if ( $2 == "" ) printf ;else print}'

Re: sed question

Tim, that looks like a winner ;-)
Sandman!
Honored Contributor

Re: sed question

>Thanks for the info, basically it currently does not work on our system, the end
>user is trying to prevent bdf output utilising 2 lines of output per file system.

In that case see the thread below:

http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=1198814
Dennis Handly
Acclaimed Contributor

Re: sed question

This does what Sandman said except it only does it for lines with ":". So using the following would work nicely:
$ bdf -t nfs | sed '/:/N^J{^Js%\n% %^J}'

>Pete: Not much:

You need to convert ^J to newlines by inserting them with ^V^J. Or use:
$ bdf -t nfs | sed '/:/N
{
s%\n% %
}'