Help with matching pattern inside a file

uname -a

env

Ok let's make it work : go in ksh first!

ksh

Then retry with nawk or /usr/xpg4/bin/awk (but not simple 'awk')

nawk -v N="$(( $(grep '>' yourinputfile | wc -l) ))" '{A[NR]=$0}END{for(i=0;++i<=N;){for(j=0;++j<=NR;)if(j%N==i%N) print A[j];print}}' yourinputfile
1 Like

It looks like the sample file is working. I will run my big file over the weekend to try to validate the results.

ctsgnb,

Can you explain to me the structure of your code? I need to understand what the i's and the j's do. How does the system know which line to retrieve and where to place them in the file.

Once again, I appreciate the help.

Great! I need to take this one step further:
I have this input file

and I want to get this output

The formula to get the value Cloumn is as follows:

Of course the program needs to scan the file to look for a parenthesis. Everytime, it sees one, put that value into a different column, performs the calculation and prints the output.
I hope you get the idea.
You are appreciated.