lundi 24 août 2015

awk if-then-else statement error

I am writing an if-then-else statement using awk in a bash script.

What I would like to do is identify lines with col 1 values not matching a particular string (rs or chr) and append a prefix (chr) to the col 1 values for those identified lines. All lines with the matched string should print as they were - no appending.

My line of code so far is:

awk '{if (! ($1 ~ /rs/ || $1 ~ /chr/)) {($1 == "chr"$1); print $0}}; else {print $0}' filename > newfilename

I keep on receiving syntax error messages with this code.

I can perform the identification and the appending successfully on their own but am having problems combining them into one command.

Aucun commentaire:

Enregistrer un commentaire