LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-03-2007, 11:11 AM   #1
nichoover
LQ Newbie
 
Registered: May 2007
Posts: 14

Rep: Reputation: 0
Converting charactors " to space


I'm looking to convert some text in a file. I'd like to change instances of a quotation mark `"` to a space. This file has multiple lines of text. Eg.

user1"place1"date
user1"place2"date
user2"place2"date

Need it to be.

user1 place1 date
user1 place2 date
user2 place2 date


Thanks in advance.
 
Old 05-03-2007, 11:25 AM   #2
pwc101
Senior Member
 
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847

Rep: Reputation: 128Reputation: 128
Code:
cat inputfile | tr """ " " > outputfile
 
Old 05-03-2007, 11:37 AM   #3
nichoover
LQ Newbie
 
Registered: May 2007
Posts: 14

Original Poster
Rep: Reputation: 0
Thank you, you got me on the right path.

I'm sure you ment this.

cat inputfile | tr "\"" " " > outputfile

Nic
 
Old 05-03-2007, 11:40 AM   #4
pwc101
Senior Member
 
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847

Rep: Reputation: 128Reputation: 128
Dammit! I thought it looked a bit funny as it was. Yeah, you need to escape the quote. You may have noticed I hadn't tested it!
 
Old 05-03-2007, 11:56 AM   #5
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
or:
sed 's/"/ /g'

This and the previous one assume that you want to change ALL the "s
 
Old 05-03-2007, 01:42 PM   #6
radoulov
Member
 
Registered: Apr 2007
Location: Milano, Italia/Варна, България
Distribution: Ubuntu, Open SUSE
Posts: 212

Rep: Reputation: 38
Quote:
Originally Posted by nichoover
[...]
Eg.

user1"place1"date
user1"place2"date
user2"place2"date

Need it to be.

user1 place1 date
user1 place2 date
user2 place2 date

[...]
Code:
IFS='"'
echo $(<file)
But this will strip trailing empty lines.
 
Old 05-03-2007, 06:34 PM   #7
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 244Reputation: 244Reputation: 244
Quote:
Originally Posted by pwc101
Code:
cat inputfile | tr """ " " > outputfile
UUOC. there's no need for cat.
Code:
tr .... < inputfile > outputfile
 
Old 05-04-2007, 04:03 AM   #8
pwc101
Senior Member
 
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847

Rep: Reputation: 128Reputation: 128
Quote:
Originally Posted by ghostdog74
UUOC. there's no need for cat.
Code:
tr .... < inputfile > outputfile
See, I'd always wondered how you did tr on its own, without cating it first. Every day's a school day! Just out of interest, why don't they make it so tr can read from a file, like sed, awk, grep etc.?:
Code:
tr "\"" " " infile > outfile
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Question about "converting" from SCO Unix to Linux... severedhead Linux - Software 4 09-15-2009 03:08 PM
Cedega "Disk space required for the installation exceeds available disk space" Solved Spewdemon LinuxQuestions.org Member Success Stories 1 10-18-2007 06:19 PM
mencoder mpegopts "not an option" format=dvd (converting avi to dvdauthor compliant) Emmanuel_uk Linux - Newbie 1 09-16-2005 01:52 PM
"no space left on device" - But df shows free space! monita Linux - General 7 03-30-2004 01:14 PM
Converting fully to Linux... help with redistribution of space ickselglic Linux - Hardware 2 03-13-2004 07:43 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:02 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration