DEV Community

Discussion on: October 2nd, 2020: What did you learn this week?

learnbyexample profile image
$ # This string 'has single' "and double" quotes and a $
$ !:q
'# This string '\''has single'\'' "and double" quotes and a $'
bash: # This string 'has single' "and double" quotes and a $: command not found

Saw this bash trick discussion at: which has other suggestions like:

  • !:q:p prevents the complaint about command not found
  • !:q and then pressing M-^ (probably Alt-Shift-6) to do the history expansion is probably more useful; then you can immediately edit the line.
  • bashquote() { printf '%q\n' "$(cat)" ; }
nickytonline profile image
Nick Taylor (he/him) Author

That's awesome! 🔥

Yes, that's awesome!