I have a file contain following output.ora.abc.db      1        ONLINE  ONLINE       serverA              Open      2        ONLINE  ONLINE       serverB              Openora.xyz.db      1        ONLINE  ONLINE       serverA              Open      2        ONLINE  ONLINE       serverB              Open      2        ONLINE  ONLINE       serverC              OpenI want to format this file in following way, but i want to use shell script only, I believe we can use awk but i don't have logic  abc  abc1  ONLINE serverAabc  abc2  ONLINE serverBxyz  xyz1  ONLINE serverAxyz  xyz2  ONLINE serverBxyz  xyz3  ONLINE serverC
How can I reformat tabular data using AWK?
text processing;awk
This can be an aproach:$ awk '/^ora/ {split($0,a,.); next} {print a[2], a[2]$1, $2, $4}' aabc abc1 ONLINE serverAabc abc2 ONLINE serverBxyz xyz1 ONLINE serverAxyz xyz2 ONLINE serverBxyz xyz2 ONLINE serverCExplanation/^ora/ applies for lines starting with ora. In those, split the content based on the dot . and store it in the array a. So it is a[1]=ora, a[2]=abc, ... Then next makes awk jump to next line.print prints the 2nd field of the array a plus different elements from the line: $1 stating for the first, $4 stating for the 4th.