![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum 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 |
| how to extract columns from a text file | ihot | Shell Programming and Scripting | 16 | 05-05-2008 08:33 PM |
| c program to extract text between two delimiters from some text file | kukretiabhi13 | High Level Programming | 5 | 01-22-2008 02:42 AM |
| How to extract text from xml file | chrisf | Shell Programming and Scripting | 3 | 09-01-2007 11:25 AM |
| merging few columns of two text files to a new file | kolvi | Shell Programming and Scripting | 4 | 09-15-2005 01:34 AM |
| How to extract data from a text file | negixx | Shell Programming and Scripting | 1 | 07-19-2005 06:30 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Extract text in 2 columns of output file.
Hello!!
I have the text file with following format... --SubTotal-----------------------------------0--161---------------44---13739369-67--- --SubTotal-----------------------------------0--147---------------0----49643---1---- --SubTotal-----------------------------------0--161---------------20---13750219-31--- --SubTotal-----------------------------------0--147---------------0----49679---0---- I want to extract bold figures in two different columns of output file. Line 1 and 3 in 1st column while line 2 and 4 in second column. Please help me in this regard. Is it possile that i pass my test file in an argument of the script. Thanks a lot. BR Danish |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Code:
sed 's/--*/-/g' filename | awk -F"-" '{ printf "%s", $6; getline; split($0, arr, "-"); printf " %s\n", arr[6] }'
|
|
#3
|
||||
|
||||
|
Quote:
Code:
awk 'NR%2?$0=$6:$0=" "$6"\n"' ORS= FS="--*" filename |
||||
| Google The UNIX and Linux Forums |