How can I make a file named "\$*'PNP'*$\" using touch command?
what I did:
% touch '"\$*'PNP'*$\"'
% ls
"\$*PNP*$\"
I need ' beside P
How can I make a file named "\$*'PNP'*$\" using touch command?
what I did:
% touch '"\$*'PNP'*$\"'
% ls
"\$*PNP*$\"
I need ' beside P
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.