![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | 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 and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| a bit tricky to change it multiple rows in one row and ... | netbanker | Shell Programming and Scripting | 2 | 01-01-2008 01:48 AM |
| Tricky Shell script | namishtiwari | Shell Programming and Scripting | 61 | 08-23-2007 07:26 AM |
| tricky search replace: Pls help. | vaibhavs | Shell Programming and Scripting | 5 | 06-11-2007 03:44 PM |
| Tricky script question | budrito | Shell Programming and Scripting | 3 | 06-30-2006 04:06 AM |
| Tricky one... | saabir | Windows & DOS: Issues & Discussions | 1 | 12-12-2002 05:34 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Tricky Sed
Hello. I am trying to convert occurrences of 'NULL' from a datafile. The 'NULL' occurences appears at this: |NULL| NULL|NULL| NULL|NULL| NULL|NULL| NULL| There should be 52 fields per line. I would like any occurrence of | NULL| or |NULL| to appear as '||' Currently I am using this sed command to convert: Code:
/usr/bin/sed -e '1,2d' -e '/^$/d' -e '$d' ${DATA}/in1.bcp > ${DATA}/trash.bcp
/usr/bin/sed -e 's/^.//g' -e 's/ */ /g' -e 's/|$//g' -e 's/000|/0|/g' -e 's/ |/|/g' ${DATA}/trash.bcp > ${DATA}/out1.bcp
/usr/bin/sed -e 's/|NULL|/|/g' -e 's/|*NULL|/|/g' ${DATA}/out1.bcp > ${DATA}/final.bcp
The problem is some fields come out like '| |' and the number of fields do not equal 52. They vary depending on how many occurrences where converted per line. Thank you for your help. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|