![]() |
|
|
|
|
|||||||
| 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 |
| Grepping for strings | t4st33@mac.com | UNIX for Dummies Questions & Answers | 5 | 06-20-2007 08:51 PM |
| matching characters between strings | akmtcs | UNIX for Dummies Questions & Answers | 9 | 12-08-2006 06:04 AM |
| How to concatenate two strings or several strings into one string in B-shell? | fontana | Shell Programming and Scripting | 2 | 08-26-2005 08:58 AM |
| ksh - strings | itzcoolbuddy | Shell Programming and Scripting | 1 | 06-22-2005 07:26 AM |
| scanf with strings... please help | inkfish | High Level Programming | 1 | 05-25-2005 02:17 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Using sed with strings of special characters
Hey, I'm having trouble figuring out the syntax for using sed with string of non-printable characters. What I have is the following format:
<field>@@;@@<field>@@;@@...@@;@@<field>@@^@@<field>@@;@@<field>@@;@@...@@;@@<field>@@^@@ ... With the @@;@@ being the delimeters between fields and the @@^@@ representing new lines. I need to replace the @@;@@ with commas, and the @@^@@ with actual new lines because there are none actually in the file. Can anyone help me out with the syntax to do this with sed or whatever would be the best option? Also, these delimeters could be changed to anything if you have any suggestions of better delimeters. Thanks. -Richard Last edited by Dickalicious; 05-25-2006 at 07:14 AM. |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Update
What I'm currently trying is the following:
nl="@@^@@" del="@@;@@" sed 's/\$nl/\012/' < temp2 > temp3 sed 's/\$del/\054/' < temp3 > temp4 but the first sed call empties the file for some reason and I can't figure out why. Any help would be much appreciated. -Richard |
|
#3
|
|||
|
|||
|
Try this
awk '{gsub(/@@;@@/,",");gsub(/@@\^@@/,"\n");printf("%s\n",$0)}' <filename>
|
|
#4
|
|||
|
|||
|
update on emptying the files
Yeah it dose empty the files
try like this nl="@@^@@" del="@@;@@" sed 's/\$nl/\012/' temp2 > temp3 sed 's/\$del/\054/' temp3 > temp4 No ideas why exactly files are becoming zero bytes.....Any one any more thought?? Cheers, Rex |
|||
| Google The UNIX and Linux Forums |