touch command help

Hi,

This might be the stupidest question ever but here it goes, i need to create a file with the name Hello! It's $s It using the touch command
but whenever i use

touch 'Hello! It's $s'
i get s is undefined

touch Hello! It's $s
i get ' unmatched

Please help :slight_smile:

FWIW, always make a directory and do these types of things in that directory just incase you make an annoying file that cannot be easily deleted.

You can use the "\" character to escape characters

touch 'Hello! It's $s' 

This would work if you didn't have three single quotes :wink:

touch "Hello! It's \$s"

Thank you so much :slight_smile:

This still isn't working it returns even with "\"
s: Undefined variable

Any suggestions?

What shell are you using?
The example previously given to you: touch "Hello! It's \$s" should work...

I see the initial problem being you used single quotes around the literal. To a computer, an apostrophe is the same as a single quote, so it took the literal as Hello! It and didn't know what to do with the s $s'

"Hello! It's $s" worked for me.

when you have problems like this, the command of the day is "script"

$ script icannottouch.txt
(new shell is created)
$ touch 'it's hard touching this file'
error too many 's
$ ^d
session saved to icannottouch.txt
$

then you can cut and paste that file to the forums. much better than 'it didnt work'