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

extract substr of more than one fields

I have a file with lines like ab.cde..fghi.jk and want to extract the leading two parts, namely ab.cde for this example.

I tried

awk -F'.' '{print $1.$2}' file

but the dot is missing. And

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

awk -F'.' '{print $1\.$2}'

raises error.

>Solution :

Literal strings need double quotes around them.

awk -F'.' '{print $1"."$2}' file
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