LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   tr to remove " from a file (https://www.linuxquestions.org/questions/linux-newbie-8/tr-to-remove-from-a-file-495784/)

ryedunn 10-26-2006 11:10 AM

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.

Wells 10-26-2006 11:29 AM

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

spirit receiver 10-26-2006 12:51 PM

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 ">" ?


All times are GMT -5. The time now is 04:12 AM.