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 and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
replace comma(,) with Tab vikas_kesarwani Shell Programming and Scripting 3 11-14-2008 02:15 AM
vi or vim replace ,$ (eol) with just a comma dbauhaus UNIX and Linux Applications 6 10-02-2008 10:02 AM
replace a newline (\n) jeter Shell Programming and Scripting 3 05-18-2008 11:37 PM
sed utility to replace /307 with comma obedkhan UNIX for Dummies Questions & Answers 1 02-06-2006 11:24 PM
How can I replace newline character? ghoti UNIX for Dummies Questions & Answers 1 08-16-2001 01:49 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 02-11-2009
eltinator eltinator is offline
Registered User
  
 

Join Date: Jul 2007
Posts: 63
Replace comma with newline

Hi, for some reason I cant seem to figure this out. I have a file which looks something like this

word
word
word
word
word,word,word
word
word
word,word,word,word,word
word
word

Basically I want this whole thing to be a list with 1 word on each line like this...

word
word
word
word
word
.
.
.

So my plan of attach was to use sed to replace the comma (,) with a newline like so:

sed 's/,/\n/g'

Which basically added a "n" where the comma was formerly. Any idea on how I can achieve my desired result? Thanks!
  #2 (permalink)  
Old 02-11-2009
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,794

Code:
tr -s ',' '\n' < oldfile > newfile

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 09:51 AM.


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