I would like to remove strings "chr" in a following txt file, using bash:
FO538757.1 chr1:183937
AL669831.3 chr1:601436
AL669831.3 chr1:601667
AL669831.3 chr1:609395
AL669831.3 chr1:609407
AL669831.3 chr1:611317
So that end file looks like:
FO538757.1 1:183937
AL669831.3 1:601436
AL669831.3 1:601667
AL669831.3 1:609395
AL669831.3 1:609407
AL669831.3 1:611317
I checked previous threads and tried:
sed 's/^chr//' awk 'BEGIN {OFS=FS="\t"} {gsub(/chr1/,"1",$2)}2'none of them worked. Is here any better option than awk?
Thank you!
You can do that quite easily with
sedand two expressions, (1) the first to removechrand the second to remove leading whitespace, e.g.Example Use/Output
With your input in the file named
file, you would have