|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
SED Help
Hi,
I am having a flat file with few data items, where I am interested with first 2 data items. The file is delimited with space as filed seperator (Sample is shown below). The first field is a BLANK the second field is 9 digit number(lines atrting with 21,42 & 111, here spaces are not visible due to html format), but this field will be embeded with spaces, now I want to replace only this blanks to zeroes for this field only. I tried with sed to do so, but it replaces whole line, How to replace only portion of the record. You help will be greatly appriciated. Thanks nmsudhan Sample 21 00000000000000000211 11 4 0 051231 42 12345600000000000042 30 0 0 100531 111 00000000000000011100 11 2 1 120229 |
|
#2
|
|||
|
|||
|
if i understand correctly, your data file will have a leading space if the first value is blank. if this is true, try the following:
PHP Code:
for your input of: PHP Code:
note that i added a line at the end that is like line 3 but with a value of 2 for the first field so that i can demonstrate the difference. the output should be: PHP Code:
Last edited by khemani : April 21st, 2004 at 08:01 AM. |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > SED Help |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|