This was originally published on my blog back in 2007, I am glad to see that this has aged well. I still find personally using many of the tricks m...
For further actions, you may consider blocking this person and/or reporting abuse
Neat tips! thanks
Here's mine:
We all know
!!but it's mostly just used tosudo !!I find
!$(which is last argument of the last command) incredibly useful:There's a whole slew of
!commands but!$is one I use all the time.You can also use
esc+.instead of!$. I find more natural and useful if you need to fix a typo.Even better! Thanks
P.S. For posterity, all of these work just as well in zsh.
Funny
$_is the exact same as!$. There's always more to learn 😀.Great write-up!
Quick note, if you are using the command edit/replace feature and are using a conditional command construct (
echo "first command" && echo "second command!") the^foo^barsyntax only replaces the first instance of the searched text.To replace every instance of that searched text, you have to use
!!:gs/foo/bar; going back to my first example:To replace all the instances of
commandin...echo "first command" && echo "second command!"...you have to execute...
!!:gs/command/echo...to output:
Further reading: Stack exchange
Yup I found out about it sometime after I wrote the original post almost 10 years ago. Thanks for the reminder!
Nice writeup! I definitely have look more into
/dev/*!I learn something new that unix tools can do basically every day 😄 In case someone is interested, I try to share those findings on a separate Twitter account: twitter.com/qvlio
Small correction: bash completion for SSH looks for
$HOME/.ssh/config, notauthorized_keysYikes my bad. Actually it should be
$HOME/.ssh/known_hostsfile for auto completing host names. You won't find host names in$HOME/.ssh/configunless you've explicitly put them there, but every host you connect to gets saved inknown_hostsby default.Yes, it does, but bash-completion does not read hosts from
known_hosts- at least on my Ubuntu 16.04 machine.It will, however, read both hostnames and host aliases from
config.So cool! I also use
$_for the arguments of the last command,echo "something"$_will be "something"This is a great article!
If you are a fan of opensource, feel free to contribute to the Introduction to Bash Scripting open-source eBook on GitHub!
+1 for the first one. 👌👌
I love shells. They are so powerful. If I can't use one on any of my devices I feel naked