ABBR DESC COL3 COL4 COL5 COL6
AAA text desc aaa text text text text
text text text text
text text text text
BBB text desc bbb text text text text
text text text text
CCC text desc ccc text text text text
text text text text
text text text text
text text text text
DDD test desc ddd text text text text
and I'm expecting the following
ABBR DESC COL3 COL4 COL5 COL6
AAA text desc aaa text text text text
AAA text desc aaa text text text text
AAA text desc aaa text text text text
BBB text desc bbb text text text text
BBB text desc bbb text text text text
CCC text desc ccc text text text text
CCC text desc ccc text text text text
CCC text desc ccc text text text text
CCC text desc ccc text text text text
DDD test desc ddd text text text text
ABBR DESC COL3 COL4 COL5 COL6
AAA text desc aaa text1 text text text
text text text text
text text text text
BBB text desc bbb text2 text text text
text text text text
CCC text desc ccc text3 text text text
text text text text
text text text text
text text text text
DDD test desc ddd text4 text text text
ABBR DESC COL3 COL4 COL5 COL6
AAA text desc aaa text1 text text text
AAA text desc aaa text text text text
AAA text desc aaa text text text text
BBB text desc bbb text2 text text text
BBB text desc bbb text text text text
CCC text desc ccc text3 text text text
CCC text desc ccc text text text text
CCC text desc ccc text text text text
CCC text desc ccc text text text text
DDD test desc ddd text4 text text text
With 149 posts to date, I'm hoping you could answer these basic questions first:-
Is this homework/assignment? There are specific forums for these.
What have you tried so far?
What output/errors do you get?
What OS and version are you using?
What are your preferred tools? (C, shell, perl, awk, etc.)
What logical process have you considered? (to help steer us to follow what you are trying to achieve)
Most importantly, What have you tried so far?
There are probably many ways to achieve most tasks, so giving us an idea of your style and thoughts will help us guide you to an answer most suitable to you so you can adjust it to suit your needs in future.
We're all here to learn and getting the relevant information will help us all.
---------- Post updated at 11:24 AM ---------- Previous update was at 11:23 AM ----------
Hi Vgersh99...
The data has tab between columns. Not working.
Appreciate your help though
---------- Post updated at 11:24 AM ---------- Previous update was at 11:24 AM ----------
rbatte1... This is not homework question.
1) did not touch unix for long time.
2) I tried prev posts here. but none of them have space in a column value. So did not get the required results.
3) So much of other deadlines to meet so not able to think properly.
Your Input_file was NOT TAB delimited, so I made it as tab delimited and tried my command and it is working fine only.
cat Input_file
ABBR DESC COL3 COL4 COL5 COL6
AAA text desc aaa text text text text
text text text text
text text text text
BBB text desc bbb text text text text
text text text text
CCC text desc ccc text text text text
text text text text
text text text text
text text text text
DDD test desc ddd text text text text
After running script:
awk 'FNR==1{$2=$2 OFS OFS;print;next}!/^ /{$1=$1;VAL=$1 OFS $2 OFS $3 OFS $4;print;next} {$1=$1;print VAL,$0}' OFS="\t" Input_file
ABBR DESC COL3 COL4 COL5 COL6
AAA text desc aaa text text text text
AAA text desc aaa text text text text
AAA text desc aaa text text text text
BBB text desc bbb text text text text
BBB text desc bbb text text text text
CCC text desc ccc text text text text
CCC text desc ccc text text text text
CCC text desc ccc text text text text
CCC text desc ccc text text text text
DDD test desc ddd text text text text
Although your real input may be tab delimited and the output you want may also be tab delimited, the sample input and output files you have provided in this thread do not contain any <tab> characters; only <space>s.
You are much more likely to get code suggestions that will work with your input data to produce the output you want if you post sample input and output that is representative of your actual data. Providing spaces in your sample input and output instead of tabs and then complaining that the code suggestions you have received don't preserve tabs is disingenuous.