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 UTF-8 characters with tr ripat Shell Programming and Scripting 2 06-26-2008 08:43 AM
Want to replace characters arndorff Shell Programming and Scripting 5 01-29-2008 04:05 PM
How to replace characters 7 through 14 of every line in a file jakSun8 Shell Programming and Scripting 9 12-13-2007 02:13 AM
Diff output, unwanted characters scanner248 UNIX for Dummies Questions & Answers 5 10-17-2007 05:23 PM
Replace Characters... lgardner17325 UNIX for Dummies Questions & Answers 8 10-26-2006 06:04 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 08-04-2008
Raghava Raghava is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 5
to replace unwanted new line characters

Hi

how to replace un wanted new line characters.
my file contains data like.

ramu,sony,"raju \n ravi \n ramya" \n
ravi,sarah,"sowmya \n sorry s\ sangam" \n

i want replace new line characters in between double coats with single space.

for example
$ cat input_file

ramu,sony,"raju
ravi
ramya"
ravi,sarah,"sowmya
sorry
sangam"

which i dont want. i want out put like below.i want replace newline s in between double quoates.

ramu,sony,"raju ravi ramya"
ravi,sarah,"sowmya sorry sangam"

any body help to find solution. either perl script or any shell script
  #2 (permalink)  
Old 08-04-2008
joeyg's Avatar
joeyg joeyg is offline Forum Staff  
modérateur
  
 

Join Date: Dec 2007
Location: Home of 17-time world champion Boston Celtics
Posts: 1,311
Question

Would this work for you?
(where new_lines is the name of your file)


Code:
cat new_lines | sed 's/" /" ~/' | tr "\n" " " | tr "~" "\n"

  #3 (permalink)  
Old 08-06-2008
chihung chihung is offline
Registered User
  
 

Join Date: Jun 2008
Location: Singapore
Posts: 48
use tr
also see ASCII - Wikipedia, the free encyclopedia to know the octal for new line, which is 012

Code:
tr -d '\012' < new_lines

  #4 (permalink)  
Old 08-06-2008
Annihilannic Annihilannic is offline Forum Advisor  
  
 

Join Date: May 2008
Location: Sydney, Australia
Posts: 1,009
This also works in most cases, and is easier to remember. :-)

Code:
tr -d '\r'

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 07:00 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