Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do escape echo " for storing in a file?

I know : echo "blah blah" >file.txt works. and that echo "" >file.txt works too.

but, what if I want to echo only ONE " (double quote) in a file.

echo ">file.txt doesn't work, is it possible doing it in a one line command?

like image 903
Joe DF Avatar asked Mar 18 '12 19:03

Joe DF


People also ask

How do I escape echo command?

echo accepts a number of escape sequences that start with a backslash. These sequences in Table A-12 exhibit fairly predictable behavior, except for \f , which on some displays causes a screen clear while on others it causes a line feed, and it ejects the page on most printers.

How do you escape characters in echo?

\e - Displays an escape character. \f - Displays a form feed character. \n - Displays a new line. \r - Displays a carriage return.

How do I echo a line to a file?

Using '>>' with 'echo' command appends a line to a file. Another way is to use 'echo,' pipe(|), and 'tee' commands to add content to a file.


1 Answers

The escape character for the Windows shell is ^, so:

echo ^" > file.txt
like image 192
Jon Avatar answered Sep 20 '22 19:09

Jon