Bash Scripting – Working of Alias | if else shell script | bash Functions & Arrays

658 views Oct 22, 2023
publisher-humix monibe.com

Bash Scripting – Working of Alias, A Bash alias is a shortcut for a command or a sequence of commands. Aliases can be used to make your life easier by saving you time and typing. To create an alias, you use the alias keyword. The alias name is followed by an equal sign (=) and then the command or sequence of commands that the alias should represent. For example, to create an alias called ll that represents the command ls -l, you would type the following command: Bash alias ll="ls -l" Use code with caution. Learn more Once you have created an alias, you can use it by typing the alias name in the terminal. For example, to run the ll alias, you would type: Bash ll Use code with caution. Learn more This would be the same as running the ls -l command. You can also create aliases that accept arguments. To do this, you enclose the arguments in parentheses after the alias name. For example, the following alias accepts a directory as an argument and lists the contents of the directory in long format: Bash alias lld="ls -l $1" Use code with caution. Learn more To use the lld alias, you would type the following command: