Hi Unix Forum,
I have a relatively easy question i suppose for which, however, until now i could not find a solution.
I am working with a program that will give me an output file similar to the following:
A
1
2
3
4
B
1
2
3
4
C
1
2
...
As the file is rather long and may variy in length for different files
i need to convert it to the following form:
A 1 2 3 4 ...
B 1 2 3 4 ...
so that ich can use gnuplot.
So far i have only found solutions for cases like:
A B
1 3
2 4
to
A 1 2
B 3 4
done with awk.
I sadly am not very familiar with awk or sed commands but i can at least make them work in a simple bash script.
I was hoping for a solution that would do for 1 file something similar to wenn i would have 2 files
A
1
2
and
B
1
2
and paste them into one file
A B
1 1
2 2
Is there any decent solution for this problem that i could use ?
Notice that the number of lines below A might vary in length.
So far i could only think of somehow scanning from the beginning to the first empty line, then write a file A.dat, continue scanning from this empty line (since B has in reality a similar value to A) to the next line, write B.dat and so on.
Then in the end i could paste all those files togehter in a bashscript, still i would not know how to script something like
paste fileA fileB ......fileXXX > total.dat
I appologize for the long description. I am not used to using forums for questions but i really would appreciate some help or
tips for tutorials that might prove helpful for this kind of problem.
Alternatively it would of course also be appropriate if it was possible to plot
this format with gnuplot directly though i doubt that.
Greetings
Leander
.
.