How to escape `$` and `#` symbols in bash?

I have a simple string I want to echo from my bash script:

$(document).ready(function() {$('#cf-footer-paragraph').append('<p>Revision 12345</p>');});

But any how I try to add \ before # I cant echo it=( So I wonder - how to echo such command?

1

1 Answer

Because you already have single quotes in the string, use double quotes, and escape only the $ sign:

echo "\$(document).ready(function() {\$('#cf-footer-paragraph').append('<p>Revision 12345</p>');});"

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like