Answer by JJoao for Remove string from a particular field using awk/sed
Just a quick coffee break answer perl -ne 's/\t.*?\tgene// #remove \t F2 \t gene and s/\S*\tID=(.*?);.*/$1/ #remove \t Fn \t ID=.... keeping the id and print' file
View ArticleAnswer by glenn jackman for Remove string from a particular field using awk/sed
The field separator of the split function is a regular expression, so you can split on = OR ;. If you know that $9 begins with "ID=", then awk -v OFS='\t' ' $3 == "gene" { split($9, id, /[=;]/) print...
View ArticleAnswer by Rany Albeg Wein for Remove string from a particular field using...
This is a Bash solution, as allowed me to publish, despite the explicit request asking to use awk and sed: show_genes() { local filename="$1" while read -ra larr; do if [[ ${larr[2]} = gene ]]; then...
View ArticleAnswer by Runium for Remove string from a particular field using awk/sed
You could split the field and use substr by: split($9, a, ";") print substr(a[1], 4) Awk indexes start at 1. Another option could be to modify the input field separator (FS). FS is space, " ", by...
View ArticleRemove string from a particular field using awk/sed
I have a file (>80,000 lines) that looks likes this: chr1 GTF2GFF chromosome 1 249213345 . . . ID=chr1;Name=chr1 chr1 GTF2GFF gene 11874 14408 . + . ID=DDX11L1;Note=unknown;Name=DDX11L1 chr1...
View Article