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 combine two awk commands into a single line

how can I combine the following two awk commands into a single line:

awk -F= '$1=="ID" { print $2 ;}' /etc/*release && awk -F= '$1=="VERSION_ID" { print $2 ;}' /etc/*release | xargs

Im trying to get the linux distribution and os in a single line, in the format distribution+version.
For example: ubuntu20.04, rhel7.5

thanks in advance

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

>Solution :

You can capture each part into a variable and then print them out once you have processed the file:

awk -F= '$1=="ID"{id=$2}$1=="VERSION_ID"{vid=$2}END{print id,vid}' /etc/*release
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