This article should only take you a couple of minutes to read, and you'll walk away with a handful of the bash tricks I constantly use.
mkdir /foo/bar && cd $_
$_ is a reference to the last parameter that was used. It can come in handy all over the place. Generally, the best use for
$_ is to avoid repeating yourself in cases like the above example.
This feature of bash is called brace expansion, it has a ton of useful applications. This is just one I sometimes use when I want to create a copy of a file quickly.
for file in * ; do cp "$file" "$file".bak; done
In this oneliner, we are taking advantage of bash's ability to loop over the files in a directory.
Frequently, I find myself using this syntax to avoid using multiple lines.
apropos "some description"
apropos is a command that looks through the commands on your machine for one that has a description like the one you provided.
It can be extremely useful when you remember what a command does, but not its name.
!! is a quick way to repeat the last command. I do this a ton.
Feel free to add your own useful bash tricks in the comments. 🤠
As we all know being a competent software developer or engineer means continuously learning throughout your career. It’s great! That makes this profession exciting and allows to escape everyday routine at work. In fact, it’s not a job anymore - it’s a lifestyle 👩💻👨💻