bash refer parameters from the current command
In bash you can use
!#
to refer to any parameter from the current command, example:
mv ak amit.!#:1.txt ls amit.ak.txt
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
}
If you have a lot of CPU power and working on battery. If you do not need that much of power and would like to rather save some battery power by disabling some cpus then you can use the below script. This script disables cpus from 4 to 7. You can change the number in the for loop. You would need the sudo to be setup or remove sudo and run the script as root. The script will show you the currently active cpu’s before and after disabling the CPU’s.
Continue reading