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

Using sed to remove string between two other stings in specific column

I want sed to look at only the first column of a tab-delimited file and remove everything between some string and the first tab for all rows. Sorry if this is repetitive, have searched other entries and cannot seem to find anything quite right.

For example, input:

blah-a_blah-b.13_blah-x_blah-y        0       0       0       0       0       17.983559

desired output:

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

blah-a_blah-b.13        0       0       0       0       0       17.983559

Tried unsuccessfully various iterations of below:

sed -i 's/\(\.[0-9]\).*\([^\t]\)//1' file

Advice?

>Solution :

This should work in gnu-sed:

sed -E 's/^([^\t]*\.[0-9]+)[^\t]+/\1/' file

blah-a_blah-b.13    0   0   0   0   0   17.983559

For non-gnu sed use:

sed -E 's/^([^[:blank:]]*\.[0-9]+)[^[:blank:]]+/\1/' 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