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
how to convert Fixed length file to delimited file. satyam_sat Shell Programming and Scripting 7 04-02-2008 11:41 PM
How to convert ^M appearing at end of line to unix newline? videsh77 UNIX for Dummies Questions & Answers 21 09-01-2007 04:21 AM
Formatting a text file based on newline and delimiter characters ntekupal Shell Programming and Scripting 5 05-11-2007 12:33 PM
Plz Help To convert xml file to text file using bourn shell scripts ram2s2001 Shell Programming and Scripting 0 11-09-2005 05:56 AM
convert XML file into Text file(fixed length) ram2s2001 Shell Programming and Scripting 0 11-02-2005 09:28 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-07-2007
Registered User
 

Join Date: May 2007
Location: Dallas, TX
Posts: 13
SED to convert ~ in a file to newline

Hi,

I have a .txt file which has a tilde(~) in it.
All that I want is to break into a newline whenever there is an occurence of '~'.
I have tried SED to do that but I could not succeed.

I would appreciate if I can get a shell script(ksh) for this problem real quick.

Thanks in advance.

-Raj.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 05-07-2007
reborg's Avatar
Administrator
 
Join Date: Mar 2005
Location: Ireland
Posts: 3,513
one way:
Code:
awk 'BEGIN{FS="~" ;OFS="\n"} {$1=$1}1' file
or another:
Code:
tr '~' '\n' < file
Reply With Quote
  #3 (permalink)  
Old 05-07-2007
Registered User
 

Join Date: May 2007
Location: Dallas, TX
Posts: 13
Thanks dude.
I think 'tr' is the better way of doing it.
Reply With Quote
  #4 (permalink)  
Old 05-07-2007
dj -------
 

Join Date: Feb 2007
Location: Cochin/Bangalore, India
Posts: 380
Did u try this in sed?

Code:
sed 's/~/\n/g' filename
Reply With Quote
  #5 (permalink)  
Old 05-07-2007
Registered User
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,397
Quote:
Originally Posted by jacoden
Did u try this in sed?

Code:
sed 's/~/\n/g' filename
Not all version of sed support \n
Code:
sed "s/~/\\
/g" filename
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 03:09 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 Global Fact Book

Content Relevant URLs by vBSEO 3.2.0