I am trying to modify text files using awk. There are three columns and I want to delete part of the text in the first column:
range=chr1 20802865 20802871
range=chr1 23866528 23866534
to
chr1 20802865 20802871
chr1 23866528 23866534
How can I do this?
I’ve tried awk '{ substr("range=chr*", 7) }' and awk '{sub(/[^[:space:]]*\\/, "")}1' but it deletes all the contents of the file.
Set the field separator as
=and print the second field:Both
awk,cutandgreprequire temporary files if you want to store the changes back intofile, a better solution would be to usesed:This substitutes
range=with nothing and the-imeans the changes are done in-place so no need to handle the temporary files stuff asseddoes it for you.