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 readingFirst you will need the ldap search utility. The client for ldap search comes in openldap-clients, so you need to install that first:
sudo yum install openldap-clients
Now, that you have installed it, try to find something in some open ldap server, example:
ldapsearch -LLL -h db.debian.org -x -b "dc=debian,dc=org" "cn=Joao*"
This should list couple of entries for you. Now, that you have ldapsearch working, lets define a function in .bashrc file:
Continue readingTo use this, you will need the lynx tool, so install that first.
sudo yum install lynx
Now, to get list of all the URLs in local html file or some URL, just execute this:
lynx -dump -listonly
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.
Just copy this script to your web-server cgi-bin directory and enjoy.
The script with show the common errors like 404 Error, Internal Server Error and others. It will show the User agent distribution using simple commands like grep, uniq, awk and so on.
You would need to change the tfile – which is temporary file and also the access.log path in the next line.
Just re-direct the output to some file with html extenstion. You could even put this in the cron which re-directs the output to some html in server document root.
Continue reading
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 reading