Quantcast
Channel: How to enclose in quotes if both single and double quotes are already used? - Unix & Linux Stack Exchange
Viewing all articles
Browse latest Browse all 6

How to enclose in quotes if both single and double quotes are already used?

$
0
0

I don't remember the exact commands and tricks that I use sometimes which solves much of the work, so I try to log them into a file for future reference. What I typically do is just put whole command in echo and append it to the file quickly.

This has always worked, but the following situation arrived for first time, where I was not able to do as stated above.

Successfull logging

$ echo "cat file1.txt | paste -d, - - ## Step 3 " >> ~/globalLog.txt

Got stuck here

$ echo "cat file2.txt  | sed 's/"//g' > file3.txt ## Step 2 " >> ~/globalLog.txt

The above is giving a obvious error, as the quotes are not being properly closed (dropping to the second command propmt (PS2 I guess?) for completing the command i.e. >_ in my case), the single(') quotes are being used by the sed command and the double(") quotes are being used in one the sed expression for replacement.

How would I enclose the complete command in such situation ?


Viewing all articles
Browse latest Browse all 6

Latest Images

Trending Articles





Latest Images