![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Rules & FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| print line whatever line i want in a file... there any way | kittusri9 | Shell Programming and Scripting | 1 | 05-15-2008 09:37 AM |
| How do i print this output all on the same line? | rcon1 | UNIX for Dummies Questions & Answers | 1 | 02-05-2008 06:52 AM |
| use variable for sed print line | atchleykl | UNIX for Dummies Questions & Answers | 2 | 04-24-2007 09:44 AM |
| awk print line | Chiefos | UNIX for Dummies Questions & Answers | 7 | 06-15-2006 02:28 AM |
| Print file line by line | handak9 | Shell Programming and Scripting | 2 | 10-20-2005 05:44 AM |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
awk print the next line on the current line
Ok I have a file with hundreds of lines, four columns, space delimited, TESTB.TXT for example
TESTB.TXT --- AA ZZ 12 34 BB YY 56 78 CC XX 91 23 DD VV 45 67 --- I want a new file that has 7 columns, the first four are identical, and the next 3 are the last three of the next line...so for example TESTB2.TXT --- AA ZZ 12 34 YY 56 78 BB YY 56 78 XX 91 23 CC XX 91 23 VV 45 67 DD VV 45 67 --- I hope I typed that right and I hope the pattern is obvious. Obviously the last line of the file wont have a next line, so its last3 columns are blank. no problem there. or if you know of a similar script just point me to it and I'll hack out the details. |
| Forum Sponsor | ||
|
|
|
|||
|
$[/tmp] > more test.txt
AA ZZ 12 34 BB YY 56 78 CC XX 91 23 DD VV 45 67 $[/tmp] > echo "" > test1.txt $[/tmp] > more test1.txt $[/tmp] > cat test1.txt test.txt > test2.txt $[/tmp] > more test2.txt AA ZZ 12 34 BB YY 56 78 CC XX 91 23 DD VV 45 67 $[/tmp] > cat test.txt | awk '{print $2 " " $3 " " $4}' > test3.txt $[/tmp] > more test3.txt ZZ 12 34 YY 56 78 XX 91 23 VV 45 67 $[/tmp] > paste test2.txt test3.txt > test4.txt $[/tmp] > more test4.txt ZZ 12 34 AA ZZ 12 34 YY 56 78 BB YY 56 78 XX 91 23 CC XX 91 23 VV 45 67 DD VV 45 67 |