The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
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

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 05-25-2006
Registered User
 

Join Date: May 2006
Posts: 6
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.
Reply With Quote
Forum Sponsor
  #2  
Old 05-25-2006
Registered User
 

Join Date: May 2006
Posts: 6
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
Reply With Quote
  #3  
Old 05-25-2006
Registered User
 

Join Date: Feb 2006
Posts: 34
Try this

awk '{gsub(/@@;@@/,",");gsub(/@@\^@@/,"\n");printf("%s\n",$0)}' <filename>
Reply With Quote
  #4  
Old 05-25-2006
Registered User
 

Join Date: Jan 2006
Posts: 43
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
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 11:31 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0