Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to print each couple of args using xargs from a list

I have this list

111
222
333
444
555

I want to print each line to have 2 coupled args, like this:

111 222
222 333
333 444
444 555
555

Is there a way to do this with xargs? or any single liner command (performance is important)

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

thanks

>Solution :

awk seems more appropriate than xargs:

$ awk 'NR>1 {print prev, $0} {prev=$0} END {print prev}' file.txt
111 222
222 333
333 444
444 555
555
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading