The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-15-2006
mightysam mightysam is offline
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
  #2 (permalink)  
Old 06-15-2006
prajith78 prajith78 is offline
Registered User
  
 

Join Date: Jun 2006
Location: Bangalore, India
Posts: 8
Code:
sed s/,/\\n/g file1
  #3 (permalink)  
Old 06-15-2006
mightysam mightysam is offline
Registered User
  
 

Join Date: Mar 2006
Posts: 5
Hi Prajith,

Its not working...

the o/p is something like this

abcdnefghn ...
  #4 (permalink)  
Old 06-15-2006
prajith78 prajith78 is offline
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
  #5 (permalink)  
Old 06-15-2006
reborg's Avatar
reborg reborg is offline Forum Staff  
Administrator
  
 

Join Date: Mar 2005
Location: Ireland
Posts: 4,211
Code:
sed 's/,/\
/g' _somefile > some_new file
** yes it should be split into two lines like this
  #6 (permalink)  
Old 09-18-2008
yahyaaa's Avatar
yahyaaa yahyaaa is offline
Registered User
  
 

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

tr "," "\n" <input_file> Output
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:37 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0