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
char c = 882 useless79 High Level Programming 1 07-30-2007 02:16 AM
char *p and char p[]. arunviswanath High Level Programming 4 07-19-2006 11:11 PM
get the last 2 char from a variable tads98 Shell Programming and Scripting 5 10-12-2005 08:45 PM
char array avadhani High Level Programming 2 07-23-2005 08:52 PM
\n char in C C|[anti-trust] High Level Programming 1 05-05-2005 03:15 PM

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

Join Date: Mar 2006
Posts: 5
How to replace any char with newline char.

Hi,

How to replace any character in a file with a newline character using sed ..

Ex:
To replace ',' with newline

Input:
abcd,efgh,ijkl,mnop

Output:
abcd
efgh
ijkl
mnop

Thnx in advance.

Regards,
Sasidhar
Reply With Quote
Forum Sponsor
  #2  
Old 06-14-2006
Registered User
 

Join Date: Jun 2006
Location: Bangalore, India
Posts: 8
Code:
sed s/,/\\n/g file1
Reply With Quote
  #3  
Old 06-14-2006
Registered User
 

Join Date: Mar 2006
Posts: 5
Hi Prajith,

Its not working...

the o/p is something like this

abcdnefghn ...
Reply With Quote
  #4  
Old 06-14-2006
Registered User
 

Join Date: Jun 2006
Location: Bangalore, India
Posts: 8
notice that 2 slashes before 'n'

its
Code:
sed s/,/\\n/g file1
NOT
Code:
sed s/,/\n/g file1
Reply With Quote
  #5  
Old 06-15-2006
reborg's Avatar
Administrator
 

Join Date: Mar 2005
Location: Ireland
Posts: 3,638
Code:
sed 's/,/\
/g' _somefile > some_new file
** yes it should be split into two lines like this
Reply With Quote
  #6  
Old 09-18-2008
yahyaaa's Avatar
Registered User
 

Join Date: May 2008
Location: Jordan
Posts: 86
try this

tr "," "\n" <input_file> Output
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 02:03 AM.


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