Issue
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:
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
Answered By - anubhava Answer Checked By - Clifford M. (WPSolving Volunteer)