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!
Using the
bashshell with Parameter Expansion andmapfileakareadarrayInside the script
extglobmust be enable but in the command line it might be enabled already, so in-one-lineIt will be very slow for large set of data/files, jfyi