Sed command usage question

How to work x in sed command?
I know x command is swaps the contents of pattern space and hold space. But i am unable to understand it's working?

Can you please be more precise and note your operating system with shell details.
Offer an example of your problem and/or make better wording.

Regards
Peasant.

1 Like

Ok,
Example is
In a file content are

a
b
c
d 
sed  'x;p;x' filename

How x will work?

Please answer the questions raised by Peasant.

All sed command operate on the pattern space; hold space is just a bucket for intermediate storage. Your code snippet swaps the line just read into pattern space with the (empty) hold space, prints that, swaps spaces again, and (by default) prints the original line.

1 Like

Yes @peasent Sir,
My operating system is ubuntu.