Re:Escaping strings in Bash using !:q
by emmelaich on Friday October 02, 2020 @02:46AM
(#24659685)
Note that you can precede the !:q with `echo` to see the result as well as the invocation without an error.
[ Parent
| on HN ]
Seeing the result of a modified history expansion is (or was) kind of a desired feature, so it's built-in just like the ability to escape stuff with :q
$ # here be quote ' " chars
(use :p to print but not execute)
$ :!q:p
'# here be quote '\'' " chars'
(use :s to modify – no :q here because we modify the already quoted text !!, unquoted is now !-2)
$ !:s/be/are/:p
'# here are quote '\'' " chars'