LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-26-2006, 12:10 PM   #1
ryedunn
Member
 
Registered: Jul 2003
Location: Chicago
Distribution: Fedora, ubuntu
Posts: 459

Rep: Reputation: 30
tr to remove " from a file


Im trying to use tr to remove all " from a file and output to a new file. Ive tried the literal, wrapping in single ' etc.. its not as easy as I thought it would be.

sed 's/"//g' document1.txt > document2.txt outputs to the screen correctly but tells me it cant find document2.

ok I found that
perl -i.bak -pe 's/"//g' document1.txt
works but that really doesnt teach me why it didnt work before.

Last edited by ryedunn; 10-26-2006 at 12:26 PM.
 
Old 10-26-2006, 12:29 PM   #2
Wells
Member
 
Registered: Nov 2004
Location: Florida, USA
Distribution: Debian, Redhat
Posts: 416

Rep: Reputation: 53
You need to escape the double quotes, so for your sed statement you would have had to do this:

sed 's/\"//g' document1.txt > document2.txt

instead of

sed 's/"//g' document1.txt > document2.txt
 
Old 10-26-2006, 01:51 PM   #3
spirit receiver
Member
 
Registered: May 2006
Location: Frankfurt, Germany
Distribution: SUSE 10.2
Posts: 424

Rep: Reputation: 33
Code:
ada@barnabas:~/tmp> cat document1.txt
john 10
"mary 20"
rick -
jack 30
ada@barnabas:~/tmp> sed 's/"//g' document1.txt > document2.txt
ada@barnabas:~/tmp> cat document2.txt
john 10
mary 20
rick -
jack 30
This works fine here. Is it possible that you forgot the ">" ?

Last edited by spirit receiver; 10-26-2006 at 01:53 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
How to remove the "^M" in some dos file naihe2010 Programming 9 09-09-2006 05:08 PM
Remove "lastlog" log file shipon_97 Linux - Security 1 07-19-2006 05:29 AM
how can i remove this file "-gxxxx" zameer_india Linux - Newbie 6 01-29-2005 03:25 AM
How to remove a file called: "-be" zepplin611 AIX 7 08-21-2004 04:37 PM
remove "special" text out of a file tearinox Linux - General 1 03-15-2004 09:43 PM


All times are GMT -5. The time now is 09:47 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration