Answer the question
In order to leave comments, you need to log in
Shorthand commands in the interpreter (bash), like in cisco ios?
Many are familiar with the Cisco IOS CLI, which allows you to use a command abbreviation if the abbreviation leads to a unique command
"Commands and keywords can be abbreviated to the minimum number of characters that identifies a unique selection. For example, you can abbreviate the "configure" command to "conf" because "configure" is the only command that begins with "conf". You could not abbreviate the command to "con" because more than one command could fit these criteria. The router will issue the following error message if you do not supply enough characters."
you can # conf t instead of # configure terminal
question: is there an equivalent for bash/sh?
ex:
[web ~]$ ps ax | gr www
-bash: gr: command not found
[web ~]$ ps ax | grep www
7505 p0 R+ 0:00.00 grep www (bash)
[web ~]$ gr
graid3 grep grn grodvi groff grog grolbp grolj4 grops grotty groups growfs
[web ~]$ gre
-bash: gre: command not found
Answer the question
In order to leave comments, you need to log in
www.linuxplanet.com/linuxplanet/tutorials/7025/1/
Do you add further?
function err_handle {
status=$?
if ; then
return
fi
lastcmd=$(history | tail -1 | sed 's/^ *[0-9]* *//')
read cmd args <<< "$lastcmd"
possible_cmd=$(ls /sbin/${cmd}* /bin/${cmd}* /usr/bin/${cmd}* /usr/local/bin/${cmd}* 2>/dev/null)
echo "Sorry, $cmd doesn't exist. Try $possible_cmd"
}
trap 'err_handle' ERR
The easiest option is to write aliases in some .bashrc:
alias gr='grep'
alias gre='grep'
The second option is to learn how to press Tab, which will add "if the reduction leads to a unique command". The problem is that there are usually more commands on Linux than on a cat. For example, gre + Tab + Tab gives me the following output:
# gre
grep gresource
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question