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“
To refer to first parameter from the last command quickly, you can use
!^
Note: This can also be referred as “!!:1“
In bash you can use
!#
to refer to any parameter from the current command, example:
mv ak amit.!#:1.txt ls amit.ak.txt
I have to several times debug scripts that I get complain about working when logging in normally but they do not work when run in cron mode. So, quite a lot of times, redirecting the stderr of the script is all that is required to see what is happening, but sometimes that just does not help if the script is calling another script which is mis-behaving and under lot of other conditions. So, how to at-least take a look at why these are failing, login with ssh.
Continue reading
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, but sometimes that
seems to be too much information and I dont really need all that. So, here
is something I found recently for bash to log all the executed commands.

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. First, check some things and set some interesting stuff.
Continue readingHere is a link of a useful 10K lines bashrc
You may not want to put the whole thing, but get an idea and use what you think can be helpful to you or at-least get an idea. This was not posted by me, so if you are re-using code as is, check the permissions to copy.
Here is a simple script that you can use as watch in Solaris as well.
watch()
{
#Poor man's watch
while (true)
do
clear
$*
sleep 2;
done
}