i am novice to the Linux shell and had to recently start using it for work…i have now got used to the basic commands in bash to find my way around…however there are a lot of commands i find myself typing over and over again and its kind of a hassle to type them every time…so can anyone tell me how can i shorten the command syntax for ones i use frequently.
A very simple example, i use the ls -lh command often, though this is quite short but im just giving an example. Can I have something (a shell script may be) so that I can run it by typing just say lh.
I want to do it for more complex commands.
If you want to make this persistent across sessions, put it in your
.bashrcfile. Don’t forget to runsource .bashrcafterwards to make bash aware of the changes.If you want to pass variables, an alias just isn’t enough. You can make a function. As an example, consider the command
lsallto list everything in a given directory (note this is just an example and thus very error prone):$Ngets replaced with the Nth argument.