Friday, 18 November 2016

linux - Print single quotes in shell script using option -c

This may sound novice but I tried everything to get this to work.
I want to print a word with single quotes : 'John' in shell script. I cant replace /bin/bash -l -c as this part of code is run by Java and I have to pass the shell command as a string. I tried with echo -e option as well.




/bin/bash -l -c 'echo "'John'"'


The output I want is:



'John'


I tried escaping the single quotes but nothing helped so far. Any ideas?

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...