If the next line is b, I want to add it to the AA line.
This is my file:
AA b b AA b AA b b b Desired output:
AA b b AA b AA b b b The below is the code I am trying.
paste -s -d" " file.txt | awk '{for(i=1;i<=NF;i++){if(i > 1 && $i == "AA")????}}' I printed several line in one line and tried to run for loop to the last field and go down to the next line if $i is AA. But I do not know what to do after the 'if' statement.
Can anyone help me?