Quote:
Originally Posted by daemonkl
then if I wanted to make this as a command, how should i proceed?
|
I would make it a shell function:
Code:
function ListAllUsers()
{
awk -F: '{print $1}' /etc/passwd
}
The "function" keyword before ListAllUsers is optional; I personally don't usually include it.
If you wanted to have it available each time you logged in, you could put it in your ~/.bashrc; if you have several functions you want to put in your .bashrc, you're probably better off putting them in a separate file, such as ~/myfunctions, and putting either
or
Code:
source ~/myfunctions
in your .bashrc (the two commands are equivalent).
FWIW, for files that I only want to source, I don't put a "she-bang" at the start of them, or mark them +x; and, I don't use the same extension for them that I do for out-right scripts. That tends to save me at least some grief.
- Larry