trying to echo a line that contains echo in a file
Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
$() says to use the returned output of the command within the parentheses. You are doing: $(date) so you are getting the actual output of the command named "date".
If you want the literal word "date" don't put $() around date but instead put quotes around it.
The file "playing" will become an executable which will later run, to show which song is playing.
The command "date" has to run, to show the date and time the song started to play. That's why I need $(date).
"date" is not working
Use of single quotes is less messy; specifically no need for '\'s
Good point and good for what the OP was doing.
I used the single quotes to day in doing a bunch of repetitive output that had things like slashes, semi-colons and brackets that would have been a bit of a pain to escape singly.
One note on it though is that the single quotes can't be used if you do want a variable expanded in one of the echo lines as I did today. The single quotes make it take ${var} literally rather than giving the value of ${var}. Not an issue in what the OP wrote but was an issue for what I was doing so for that one line I did have to do double quotes. Luckily that one line didn't also require me to escape anything else on the line but I could see situations where it would.
Just posting to note there are times when both are appropriate.
Last edited by MensaWater; 01-05-2016 at 03:30 PM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.