Full Discussion (Bash Shell Tricks)

Neat tips! thanks

Here's mine:

We all know !! but it's mostly just used to sudo !!
I find !$ (which is last argument of the last command) incredibly useful:

#make a directory and go to it
mkdir workspace
cd workspace

# OR even better
mkdir workspace
cd !$

# move then edit a file
mv ~/somefile.txt ~/renamed.txt
vim !$

# edited a file, now add it to git
vim awesome_code.c
git add !$

There's a whole slew of ! commands but !$ is one I use all the time.

Funny $_ is the exact same as !$. There's always more to learn 😀.

code of conduct - report abuse