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  bDesired output:AA b b  AA b  AA b b bThe 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? 
How to print next line on current line if next line contains some character?
text processing;awk;sed