![]() |
|
|
|
|
|||||||
| 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 |
| need for loop to include fields as one line | prkfriryce | Shell Programming and Scripting | 8 | 03-23-2007 09:49 AM |
| fill a NIL into the blank field | happyv | Shell Programming and Scripting | 8 | 03-23-2007 01:49 AM |
| field separator as regexp | Abhishek Ghose | Shell Programming and Scripting | 2 | 02-15-2006 05:49 PM |
| awk: How to check if field is blank? | yongho | Shell Programming and Scripting | 7 | 06-09-2005 08:35 AM |
| How do I specify tab as field separator for sort? | SSteve | UNIX for Dummies Questions & Answers | 8 | 04-26-2005 01:39 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#8
|
||||
|
||||
|
vgersh99
The o/p wants to detect the absence of field2 and field3. vino |
| Forum Sponsor | ||
|
|
|
#9
|
|||
|
|||
|
empty fields are also spaces. but i need them to be shown as a blank in the output.
|
|
#10
|
|||
|
|||
|
Quote:
|
|
#11
|
||||
|
||||
|
If field2 and field3 always follow a same pattern, then look for its absence, and introduce a ;
Vino |
|
#12
|
|||
|
|||
|
Quote:
however, the number of fields in each line is the same. i am not sure if this will be a helpful pt to make use of |
|
#13
|
||||
|
||||
|
Add this as well to the original solution.
Code:
sed -e 's/^\([0-9][0-9]*\);\([0-9][0-9]*\)$/\1;;;;\2/g' Vino |
|
#14
|
||||
|
||||
|
A hint: Looks like each field starts and ends in well defined columns with a variable number of trailing spaces to fill the field. You're going to need to exploit that property for a correct solution. We need the starting column numbers. With a modern sed, it is an easy two step process. Deposit a separator after, say, columns 10, 15, 20, 40. Then remove spaces before the separator.
|
||||
| Google The UNIX and Linux Forums |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|