Reputation: 135
How can I make a file named "\$*'PNP'*$\"
using touch command?
what I did:
% touch '"\$*'PNP'*$\"'
% ls
"\$*PNP*$\"
I need ' beside P
Upvotes: 2
Views: 56
Reputation: 113924
One approach is to put the desired filename in a Try:
$ touch "\"\\\$*'PNP'*$\\\""
$ echo *PN*
"\$*'PNP'*$\"
If you run ls
, be aware that it may put escapes in the file name:
$ ls
'"\$*'\''PNP'\''*$\"'
In the above touch
command, escapes are required. First, to put a double-quote inside a double-quoted string, it must be escaped as \"
. Second to put a backslash in a double-quoted string, it must also be escaped as \\
. Inside a double-quoted string, '
does not need to be escaped.
$ touch '"\$*'\''PNP'\''*$\"'
$ echo *PN*
"\$*'PNP'*$\"
The above has five strings:
'"\$*'
\'
'PNP'
\'
'*$\"'
Strings 1, 3, and 5 are single-quoted strings. Strings 2 and 4 are unquoted but escaped single-quotes.
Upvotes: 2