I want to simply define a custom shell command, for example:
I type abc
and it will output some text.
Like:
$ abc
The quick brown fox jumps over the lazy dog.
- How to make it simply in Linux?
I want to simply define a custom shell command, for example:
I type abc
and it will output some text.
Like:
$ abc
The quick brown fox jumps over the lazy dog.
Try alias
alias abc="echo The quick brown fox jumps over the lazy dog."
you can add it into your ~/.bash_profile to make it valid for all sessions.
You also should consider learning about bash functions so you would have
function abc () {
echo The quick brown fox jumps over the lazy dog.
}
and as others told you, you could also use bash alias
builtin.
You may want to remove the bash-specific function
keyword to be portable to other Posix shells.
The main advantage of functions in bash is that they can take some arguments and be more complex than what alias
give you.
If i have understood your requirement correctly ,you can use alias command for this
alias abc='echo "testing"'
alias abc='echo The quick brown fox jumps over the lazy dog.'