
grep sTerm * | grep -v grep ???
On Sat, 8 Dec 2001 mmcnal...@prodigy.net wrote:
An alias doesn't know about positional parameters.
If you type:
r cron
it expands to:
ps ax | grep $1 | grep -v grep cron
which is not what you want at all.
Use a function instead:
r() {
ps ax | grep "[${1%${1#?}}]${1#?}"
}
The gobbledygook places square brackets around the first character of the
argument so that it won't match itself, and you don't need the second
grep.
A shorter way, but not POSIX compliant (it works in bash and ksh93) is:
ps | grep "[${1:0:1}]${1:1}"
man bash:
. filename [arguments]
source filename [arguments]
Read and execute commands from filename in
the current shell environment and return
the exit status of the last command exe-
cuted from filename. If filename does not
contain a slash, file names in PATH are
used to find the directory containing file-
name. The file searched for in PATH need
not be executable. When bash is not in
posix mode, the current directory is
searched if no file is found in PATH. If
the sourcepath option to the shopt builtin
command is turned off, the PATH is not
searched. If any arguments are supplied,
they become the positional parameters when
filename is executed. Otherwise the posi-
tional parameters are unchanged. The
return status is the status of the last
command exited within the script (0 if no
commands are executed), and false if file-
name is not found or cannot be read.
(Not all shells will allow arguments.)
--
Chris F.A. Johnson http://cfaj.freeshell.org
===================================================================
My code (if any) in this post is copyright 2001, Chris F.A. Johnson
and may be copied under the terms of the GNU General Public License