Get count of lines in scripts (shell)


If you have tried to get the count of lines in file, the you would know about “nl” or “wc -l”. But as you are aware these give you number of lines with other details as well and you need to post …

bash – refer the first parameter from last command quickly


To refer to first parameter from the last command quickly, you can use !^ Note: This can also be referred as “!!:1“

bash refer parameters from the current command


In bash you can use !# to refer to any parameter from the current command, example:


bash debug – log all executed commands


Whenever I am writing a script in perl or bash, I always wish that there was some way to have all the commands logged or output to screen. I know there is “set -x” option to have debugging enabled, …

bash – using the vi mode more effectively.


You can first set the bash mode to vi. This will enable some vim like features to bash. So, add this to .bashrc : set -o vi Once, you have done that then its time to get more out of the vi mode. …

Shortcut to run current command with sudo in bash


For me, I mostly forget to add “sudo” to the command until the time I am actually supposed to run it. Also sometimes, on some systems, bash completion does not work as expected with “sudo”. With these …

Array of all possible colors in bash script


Sometime back, we had looked at using colors in bash script and here is a way to create a array of all the colors. #!/bin/bash - …

colors in bash scripts


I have been trying to understand the color codes for bash for a pretty long time, but somehow never got time to understand this clearly. So this time around when I was writing a script to analyze some …

bash prompts — some good links


Here are some pretty good links on the subject. Since there are already so many blog posts, does not make sense to add one more 🙂 …


15 Linux Bash History Expansion Examples You Should Know


Here is a nice link on BASH History Expansion. There are lot of examples in this page and some of them might be quite useful. But here are my list of favourites: !! This is probably the most used one …

some interesting alias


For this time, I will just give you a link to to bashrc file. Head over there and see some very interesting aliase’s.

better bash debugging


I was trying to debug some bash scripts yesterday and learnt something new 😉 There are lot of things in bash that you can use to debug and to start with you can enable xtrace mode as follows: set -x …

This website uses cookies to ensure you get the best experience on our website. Learn more Got it