Question on passing multiple parameters in if


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Question on passing multiple parameters in if
# 1  
Old 05-09-2010
Java Question on passing multiple parameters in if

Hi All,
My target is to find the list of orphan processes running and i issue the below command with some exception ids.
Code:
 
ps -ef | egrep -v "root|system|admin" | awk '{if ($3 == 1) print $1",\t"$2",\t"$3}'

but this will exclude the process having the word 'root' and executing under different user id (not root).
To achieve this, i planned to do a positional egrep to get rid off the above scenario and below is the code:
Code:
 
ps -ef | egrep -v "^.{4}root|^..system|^...admin" | awk '{if ($3 == 1) print $1",\t"$2",\t"$3}'

this works but if there are more user id's need to be added in the exception list then the line grows bigger, to shorten this to a bit i tried the below one:
Code:
 
ps -ef | awk '{if ($3 == 1 && $1 != "root||system||admin") print $1",\t"$2",\t"$3}'

but not getting any output and i know the issue is due to passing multiple strings in a single condition... please correct me.
Is there any alternative/simple solution exists? Thanks for your help in advance!
# 2  
Old 05-09-2010
Try:
Code:
ps -ef | awk '{if ($3 == 1 && $1 !~ /root|system|admin/) print $1",\t"$2",\t"$3}'

Jean-Pierre.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Python passing multiple parameters to functions

Hi, I am a beginner in python programming. In my python script have a main function which calls several other functions. The main function gets its input by reading lines from a input text file. I call the main function for every line in input text file through a loop. def main(line): var1... (6 Replies)
Discussion started by: ctrld
6 Replies

2. Shell Programming and Scripting

Help with passing parameters from a file

Hello Everyone, I have developed a shell script which takes schema id and password as parameter to login into database using sqlplus,runs a query and mails the result. My requirement is that, I dont want to pass userid and password as parameters.Instead,I want to pass say Environment... (4 Replies)
Discussion started by: karthik adiga
4 Replies

3. Shell Programming and Scripting

Passing Parameters to Crontab

Hello Experts, I have a requirement to pass some parameters to Linux cron tab. For ex: My default cron entry looks like this as below: ------------------------------- 55 10 * * --... (7 Replies)
Discussion started by: MaheshChaudhari
7 Replies

4. Shell Programming and Scripting

Passing 2+ parameters to one command

I have a script that uses more than one parameter. It looks like this: for i in `cat /tmp/listofpolicies`; do for x in $(cat /tmp/lst |sed 's/^/\/usr\/openv\/netbackup\/db\/class\//g'); do /usr/openv/netbackup/bin/admincmd/bpplinclude $i -delete -f $x;done;done The problem is that the... (3 Replies)
Discussion started by: newbie2010
3 Replies

5. Shell Programming and Scripting

passing parameters with spaces

we are using following script to execute stored procedue. The problem is run_pmcmd.ksh script is using $* parameter which is not taking in account 'Men Shirt' parameter which includes spaces. 1. Step 1 run_pmcmd.ksh CONVERT_TEST script for run_pmcmd.ksh /u01/$(whoami)/run_pmcmd.ksh... (11 Replies)
Discussion started by: sandy162
11 Replies

6. Shell Programming and Scripting

Passing the parameters using a function

Hi All, I am new to shell scripting required some help in passing the parameter value to the shell script. I am writing a shell script, in the script I have created two functions as below. first function get_trend_ids () { Here I am connecting to the database and getting all the... (3 Replies)
Discussion started by: shruthidwh
3 Replies

7. Shell Programming and Scripting

passing multiple files as parameters

hi all i am etl guy i have shell script that i use to do processing on file. the problem is that i want it to use on multiple files at same time is there any way of passing the file name since my all my filename start with samename like abc* p,ease let me know (4 Replies)
Discussion started by: er_zeeshan05
4 Replies

8. Shell Programming and Scripting

passing more than 9 parameters

hi, i am passing around 14 parameters for a script a=$1 b=$2 c=$3 d=$4 e=$5 f=$6 g=$7 h=$8 i=\"${9}\" shift j=\"${1}\" still for j it is displaying the 1st parameter value..how to make it take the 10th parameter (2 Replies)
Discussion started by: dnat
2 Replies

9. Shell Programming and Scripting

Passing parameters through a file

I have created a script "myscript.sh" I need to run this script with diffrent parameters. The parameters are stored in a file myparam.txt. I need to run myscript.sh script for every parameter supplied in myparam.txt. Example: If myparam.txt contains following lines: param1 param2 param3... (3 Replies)
Discussion started by: chawlaaman
3 Replies

10. UNIX for Dummies Questions & Answers

Passing parameters in script

I have 2 scripts: script1 and script2 Script1 passes 4 parameters to script2 as follows #script1 code ... ... script2 $var1 $var2 $var3 $var4 Script2 uses the export command to know to expect these values #script2 export $1 $2 $3 $4 code ... ... The problem that I am having is... (1 Reply)
Discussion started by: eliguy
1 Replies
Login or Register to Ask a Question