Life become much easier with command line (CLI) tools
Over the last few years I have moved away from windows operating system to mac & as time passed I came across many cool/handy command line tools which can make developers life easy.
Here are some of my favorite command line tools which I will be discussing it over this blog post
- bat
- ripgrep
- speedtest-cli
- jq
bat
Bat is a command line tool that has the same functionality as the cat command but then it displays the contents with syntax highlighting, line numbers and file name.
How to install?
brew install bat
or
apt install bat
How to use?
We would have used cat command like below to print the contents of the file in terminal using the below like command.
cat main.go
Here is the same command with the bat
bat main. Go
See how well it is presented for the same file. You can notice line numbers with name of the file at the top and with syntax highlighting. Here in the above example it is goLang code accordingly it is highlighting.
More
To know more about the command you make use of the flag —help
bat --help
ripgrep
Many of us would be familiar with grep command but then ripgrep will do the same functionality in a super fast way and then in much better way. More on benchmarks and other details can be found at https://github.com/BurntSushi/ripgrep
How to install?
brew install ripgrep
or
apt install ripgrep
How to use?
Here how you can use it
rg func
Here I am looking for text func from the folder.
By default simple text search is case sensitive. Lets now search another phrase with a flag -S
rg start -S
Beauty here it has highlighted the matched phrase in red.
More
To know more about the command you make use of the flag —help
rg --help
You can find cheat sheet at https://jdhao.github.io/2020/02/16/ripgrep_cheat_sheet/
speedtest
Command line interface for testing internet bandwidth using speedtest.net.
How to install?
brew install speedtest-cli
or
apt install speedtest-cli
How to use?
speedtest
The above command will run for few seconds and result will return something like
Retrieving speedtest.net configuration...
Testing from ****net (146.51.73.34)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by ****net Ltd (Location) [426.33 km]: 30.522 ms
Testing download speed................................................................................
Download: 655.24 Mbit/s
Testing upload speed......................................................................................................
Upload: 540.61 Mbit/s
In case, If you want the response in JSON format then you can use flag like —json
{
"download": 579246650.21143097,
"upload": 595146748.3680651,
"ping": 30.961,
"server": {
"url": "<http://speedtest.minnaldigital.com:8080/speedtest/upload.php>",
"lat": "13.670",
"lon": "47.7604",
"name": "****",
"country": "India",
"cc": "IN",
"sponsor": "**** Digital Network Pvt Ltd",
"id": "43388",
"host": "speedtest.****.com:8080",
"d": 17.52664529109865,
"latency": 30.961
},
"timestamp": "2023-09-13T13:59:06.487041Z",
"bytes_sent": 151519232,
"bytes_received": 409373932,
"share": null,
"client": {
"ip": "16.56.73.134",
"lat": "14.9634",
"lon": "67.5855",
"isp": "****net",
"isprating": "3.7",
"rating": "0",
"ispdlavg": "0",
"ispulavg": "0",
"loggedin": "0",
"country": "IN"
}
}
There are many other flags like —single incase if you want Only use a single connection instead of multiple. This simulates a typical file transfer.
More
To know more about the command you make use of the flag —help
speedtest --help
or you can find more information at https://github.com/sivel/speedtest-cli.
JQ
JQ is a lightweight and flexible command-line processing tool which can be used for transforming JSON data to desired text format, can be used for filtering, restricting & extracting specific properties from the JSON.
I have discussed about this command line tool in details at https://shiljopaulson.medium.com/jq-a-lightweight-command-line-processing-tool-for-json-75b3390530c6
Please share your valuable feedback and do like incase you liked the post which encourages me to blog more.