shell script to edit a file
i have a file called number which contains data as
1 2 3 4 5 6 7 8 9 0 9 8 7 6 5 4 3 2 1 0 0 1 2 3 4 needed a shell script to print the output as 1 7 7 1 4 and 1 2 3 4 5 6 7 8 9 9 8 7 4 3 0 |
Please tell me this is not homework.
Awk solutions are quite simple: Code:
awk '(NF>i) { i++ ; print $i }' number Code:
awk '(NF>0) { if (NF>m && n<1) { n=NF; m=NF } ; printf("%s", $1); for (i=2; i<=n; i++) printf(" %s", $i); printf("\n"); n-- }' number |
Quote:
|
Quote:
@jacky29: a good attitude here would be to show what have you tried so far and ask for some specific questions if stuck at some point. Not simply ask "Do a script for me!". If this is really homework, you have to show your effort in the learning process and the willingness to solve the problem by yourself, not only to copy homework from your friends. Nuff' said. |
Quote:
|
All times are GMT -5. The time now is 11:19 PM. |