slim_will
slim_will

Reputation: 1

Hi i have to create a file that is named exaclty like this "\?$*'ChouMi'*$?\" in bash

I tried everything i found to achieve this but everytime the '' around ChouMi are not displayed with the ls | cat -e command how can I do it please ?

Here what it is expected

Upvotes: 0

Views: 340

Answers (1)

KamilCuk
KamilCuk

Reputation: 141493

Hi i have to create a file that is named exaclty like this “\?$*'ChouMi'*$?\” in bash

Just quote the string properly. There a cool trick to it. Open a file and output the text you want to quote:

“\?$*'ChouMi'*$?\”

save the file and do:

$ xargs -d'\n' printf "%q\n" < your_file
'''“\?$*'\''ChouMi'\''*$?\”'

The xargs -d '\n' read lines from /tmp/file and appends them as command line options to printf. < your_file redirects the content of the file to xargs so it can read from it. Then printf %q\n prints quote-quoted output of the arguments. Now you can copy whatever the text is and pass it to a command to create a file:

$ touch '''“\?$*'\''ChouMi'\''*$?\”'
$ ls
'“\?$*'\''ChouMi'\''*$?\”'

Upvotes: 1

Related Questions