 |
 |
Alias Syntax Correct?
|
 |
|
 |
|
Junior Member
Join Date: Oct 2000
Status:
Offline
|
|
hi all,
the following doesn't seem to give the correct output when used as an alias... is the syntax correct?
alias psf "ps -auxww | grep \!:1 | grep -v grep | awk '{print $2}'"
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: May 2001
Status:
Offline
|
|
Yes, it is correct for tcsh.
-
|
|
|
| |
|
|
|
 |
|
 |
|
Junior Member
Join Date: Oct 2000
Status:
Offline
|
|
thanks for the reply moonray.
thing is it doesn't work when the commands are combined into an alias. the grep results don't seem to be awk'ed. 
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Nov 2001
Location: Adelaide, South Australia
Status:
Offline
|
|
Originally posted by zoe77:
thanks for the reply moonray.
thing is it doesn't work when the commands are combined into an alias. the grep results don't seem to be awk'ed.
Welcome to the hideous world of tcsh quoting. Not a nice place to land. Maybe this will help you out...
alias psf 'ps -auxww | grep \!:1 | grep -v grep | awk '\\''{print $2}'\\'' '
(Yep, *lots* of single quotes in there. Please cut and paste when you're tying it out!) I wish to plead "not guilty" to creating such a monstrous construction: I just hunted around in /usr/share/tcsh/examples/aliases for a similar beast and there it was...
Cheers,
Paul
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: May 2001
Status:
Offline
|
|
Originally posted by zoe77:
thanks for the reply moonray.
thing is it doesn't work when the commands are combined into an alias. the grep results don't seem to be awk'ed.
Oops yes. Sorry I didn't pay attention to that detail. The reason is that the shell expands the $2 if it is enclosed by double (or no) quotes instead of passing it to awk. Paul McCann's version should work fine, or if you want the double quotes, use:
alias psf "ps -auxww | grep \!:1 | grep -v grep | awk '{print "'$2'"}'"
or if you want less quotes:
alias psf ps -auxww | grep \!:1 | grep -v grep | awk '{print $2}'
Hope that helps.
-
|
|
|
| |
|
|
|
 |
|
 |
|
Junior Member
Join Date: Oct 2000
Status:
Offline
|
|
thanks Paul this works perfectly!
Originally posted by Paul McCann:
Welcome to the hideous world of tcsh quoting. Not a nice place to land. Maybe this will help you out...
alias psf 'ps -auxww | grep \!:1 | grep -v grep | awk '\\''{print $2}'\\'' '
Cheers,
Paul
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |