Linux users know that the shell itself is a productivity booster on its own. As an old Chinese proverb says: “One shell commands is worth a thousand mouse clicks.”
Here are five one-liners which you can use every day to increase your productivity. I have tested all commands on Ubuntu 20.10 and bash 5.2
.
“One shell command is worth a thousand mouse clicks.”
— Old Chinese proverb
1. Pretty-Print a CSV file
CSV files are omnipresent. You can pretty-print them to the terminal via:
Username; Identifier;First name;Last name
booker12;9012;Rachel;Booker
grey07;2070;Laura;Grey
johnson81;4081;Craig;Johnson
jenkins46;9346;Mary;Jenkins
smith79;5079;Jamie;Smith
$ column -s';', -t < your_file.csv
Username Identifier First name Last name
booker12 9012 Rachel Booker
grey07 2070 Laura Grey
johnson81 4081 Craig Johnson
jenkins46 9346 Mary Jenkins
smith79 5079 Jamie Smith
2. Convert a UNIX timestamp to a human-readable date
So, what date is 1234567890 again? Just use:
$ date -d @1234567890
Fri Feb 13 23:31:30 UTC 2009
To get the current date and time as a timestamp, run:
date +%s
3. Get all programs which listen on a port
Sometimes, starting an application which needs a port results in a failure. Another application is using this port. Find out which application it is with:
$ lsof -i:yourport
You can get a list of all used ports if you omit the port from the command:
lsof -i
4. Find your public IP address
Speaking of ports, sometimes you need to know what your public IP is. For example, you may have to check if you correctly use the VPN.
The easy way to find it out is:
# Get your IPv6 adress
curl -6 curlmyip.net
# Get your IPv4 address
curl -4 curlmyip.net
5. Remove all files which do not have a given ending
My download folder is often a mess. But what is the easiest way to keep all the important PDFs and EPUBs and get rid of the rest? The following command will do the trick:
rm !(*.pdf|*.epub)
Thank you for investing your time in reading this post! 🙏 If you found it valuable, please leave a comment 💬 and share it with your network 📢.