Could somebody gently point out the error of my ways in the below (the flu I'm fighting might be contributing to my current haplessness)
awk -F="\t" \
'{
for (i = 1; i <= NR; i++);
FNR == i;
{
if (length($3) < 56 && length($1) > 56)
$1=($1" "$2); $2=$3; $3=$4;
{j=5; while (j < NF) {$3=($3" "$j); j++} };
else
{j=4; while (j < NF) {$3=($3" "$j); j++} };
}
print $1 "\t" $2 "\t" $3 "\t" $(NF)
}
END {}'
With no sample input, no indication of what your script is supposed to do, no desired output, no indication of what operating system you're using, and no indication of what errors you're getting; it is hard to suggest what you need to do to fix your problems.
But, here are a couple of comments that may help you decide what you want to change...
1 awk -F="\t" \
2 '{
3 for (i = 1; i <= NR; i++);
4 FNR == i;
5 {
6 if (length($3) < 56 && length($1) > 56)
7 $1=($1" "$2); $2=$3; $3=$4;
8 {j=5; while (j < NF) {$3=($3" "$j); j++} };
9 else
10 {j=4; while (j < NF) {$3=($3" "$j); j++} };
11 }
12 print $1 "\t" $2 "\t" $3 "\t" $(NF)
13 }
14 END {}'
The if statement on lines 6 and 7 is treated as:
6 if (length($3) < 56 && length($1) > 56)
7 $1=($1" "$2);
The remainder of line 7 contains two assignment statements that are executed independently of whether or not the expression in the if statement is true or false.
The else on line 9 is not associated with an if statement.
The END {} on line 14 can be removed without affecting the operation of your awk script.