Hello,
I have a some files that look like this:
0 3
1 5
2 8
3 7
I want to reverse and append the data so it looks like this:
3 7
2 8
1 5
0 3
0 3
1 5
2 8
3 7
I first thought about using cat and tac cleverly with some redirection and pipe in a one-liner but I couldn't get it to work.
What I do now is the following:
for i in log*
do awk '{ a[i++] = $0 } END { for (j=i-1; j>=0;) print a[j--]; for (j=0; j<=i-1;) print a[j++]}' $i > $i.new
mv $i.new $i
done
Actually I would like to do something like this:
tac log1 | cat >> log1
but the result of tac log1 is now at the end of log1 instead of at the beginning. Is it possible to use the second option somehow in a oneliner but with the result of tac log1 at the beginning of log1?
Thanks in advance