#This is the error command egrep "smtp" -i ./production.log #Would like to correct it with !! to have this: (whitout taping it again) egrep -i "smtp" ./production.log
Refactorings
No refactoring yet !
GeekBoi
July 29, 2009, July 29, 2009 19:20, permalink
Not sure that it saves you that much but here is one option.
#This is the error command egrep "smtp" -i ./production.log # Have to type the command again rather than useing !! then append the arguments from the previous command. egrep !:2 !:1 !:3
Pascal Charest
September 9, 2009, September 09, 2009 19:31, permalink
Here, add this function to your $home/.bashrc file. This will intercept any call made through the shell to egrep and rewrite it if needed. It catch the case where $2 is -i and rewrite the command.
You must validate that egrep is present at /bin/egrep (could refactor to add the which function).
function egrep {
echo "command used:"
echo "egrep" $@
if [ $2 = "-i" ]
then
echo "wrong syntax, we are rebuilding"
/bin/egrep $2 $1 $3
else
/bin/egrep $@
fi
}
I looking for a quick easy way to change this command. I would like to use the !! command with bash to put the -i at the correct place: