DEV Community

loading...

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

Collapse
learnbyexample profile image
Sundeep
$ # 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: news.ycombinator.com/item?id=24659282 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)" ; }
Collapse
nickytonline profile image
Nick Taylor (he/him) Author

That's awesome! 🔥

Yes, that's awesome!