![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| passing variable from bash to perl from bash script | arsidh | Shell Programming and Scripting | 10 | 06-04-2008 09:25 AM |
| Why generate "ash and bash" different output for same bash script? | s. murat | Shell Programming and Scripting | 0 | 05-26-2008 04:19 AM |
| alias | klannon | Filesystems, Disks and Memory | 6 | 04-27-2006 05:36 AM |
| alias help | shafique | HP-UX | 4 | 11-20-2005 12:19 AM |
| Query regarding alias and setting bash as a default script | VENC22 | UNIX for Dummies Questions & Answers | 1 | 07-13-2005 06:18 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
bash alias help
I try the following alias:
alias psx='ps auxw | grep $1 | grep -v grep' but it fails with "grep: yyy: No such file or directory" (for 'psx yyy' command). the following is ok: alias psx='ps auxw | grep $1' why this happens? how to overcome this? thanks |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
An alias cannot have an argument like $1. You want to use a function instead.
Code:
psx () {
ps auxw | grep "$1" | grep -v grep
}
Your first alias expands to ps auxw | grep (empty string) | grep -v grep yyy Search these forums for ways to avoid the grep -v grep elegantly; solutions have been posted a number of times. |
|
#3
|
|||
|
|||
|
You might it helpful to investigate the pgrep command if it is available on your system (I think it is on Solaris and Linux).
|
|
#4
|
|||
|
|||
|
thanks!
Apparently many make this mistake, I found more than once $1's for aliases in .bashrc files... |
|||
| Google The UNIX and Linux Forums |