Reputation: 1313
I am attempting to run the following command:
cat file.txt | tr -d "{\"" > output.txt
But it keeps erroring with:
tr: extra operand '>'
It seems like it's not interpreting the carrot properly. The same thing also happens when I try this:
tr -f "{\"" < input.txt > output.txt
tr: extra operand '<'
Upvotes: 0
Views: 1029
Reputation: 6123
It looks like cmd
is getting confused with "{\""
. First, the backslash works correctly in escaping the quote. But two consecutive quotes are taken by cmd to mean an escaped quote. Then the rest of the line is taken as the same sentence. You can see the effect using printf
:
C:\>printf "%s\n" "x\"" > nul
x"
>
nul
Thus, printf
takes each word individually, but cmd
sees them as all part of a quoted string, and therefore does not parse the > nul
as anything other than normal words.
The solution? Use two consecutive quotes in your string:
cat file.txt | tr -d "{""" > output.txt
Upvotes: 2