Counting


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Counting
# 1  
Old 10-30-2010
Counting

Hi,
The following output shows how many pmon process are started by users named : oracle or yoavb
Code:
[/home/yoavb]$ ps -ef |grep pmon |grep -v grep |grep -v ipmon
  oracle 11268     1  0  Sep  2  ?        36:00 ora_pmon_qerp
  oracle 17496     1  0  Oct 11  ?         8:58 ora_pmon_bcv
  oracle 15081     1  0  Sep  6  ?        19:08 ora_pmon_trn
  oracle  5310     1  0  Oct 14  ?         7:19 ora_pmon_bildev
  yoavb  25467     1  0  Oct 24  ?         2:44 ora_pmon_qa2

I Would like to know, how to count (wc -l) how many process DID NOT started by user ORACLE
Thanks

Last edited by Scott; 10-30-2010 at 08:43 PM.. Reason: Code tags
# 2  
Old 10-30-2010
try:
Code:
grep '_[p]mon_' | grep -v "^oracle" | wc -l

Code:
sed '/_[p]mon_/!d;/^oracle/d' | wc -l

Code:
awk '/_[p]mon_/ && $1!="oracle"' | wc -l

Code:
awk '/_[p]mon_/ && $1!="oracle"{i++} END{print i}'

# 3  
Old 10-30-2010
you dont have to use `wc -l` Smilie
Code:
# ps -ef | sed -n '/^[^oracle].*[^a-z*]pmon/p'|sed -n '$='

# 4  
Old 10-30-2010
Code:
ps -ef |awk '$1!="oracle"&&!/_[p]mon_/ ' |wc -l

ps -ef |awk '$1!="oracle"&&!/_[p]mon_/ {sum++}END{print sum}'

# 5  
Old 10-31-2010
Quote:
Originally Posted by ygemici
you dont have to use `wc -l` Smilie
Code:
# ps -ef | sed -n '/^[^oracle].*[^a-z*]pmon/p'|sed -n '$='

You do not have to use wc -l, but sed is much less efficient. See:
https://www.unix.com/shell-programmin...wc-l-2.html#13

Quote:
Originally Posted by rdcwayx
Code:
ps -ef |awk '$1!="oracle"&&!/_[p]mon_/ ' |wc -l

ps -ef |awk '$1!="oracle"&&!/_[p]mon_/ {sum++}END{print sum}'

That should be &&/_[p]mon_/, no?
# 6  
Old 10-31-2010
MySQL

Quote:
Originally Posted by Scrutinizer
You do not have to use wc -l, but sed is much less efficient. See:
https://www.unix.com/shell-programmin...wc-l-2.html#13
yes i already save this in my notes thanks a a lot of for usefull infos Smilie Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sequential counting

Hi have a file of the following format a1 a1 a2 a2 a4 a4 a4 a3 a3 a5 a6 a6 a6 a6 .. 100's of lines (2 Replies)
Discussion started by: Lucky Ali
2 Replies

2. UNIX for Dummies Questions & Answers

counting?

Hi all, I promise this is my very last dumb question.. but how to you count how many unique names you have. My dataset is: >Bac1 afdsgrr >Bac4 egege >Bac8 dgrjh >Bac1 afdsgrr >Bac1 afdsgrr >Bac8 dgrjh What i want to know is that how many unique names there is, so the output would... (3 Replies)
Discussion started by: Iifa
3 Replies

3. Shell Programming and Scripting

counting using awk

Hi, I want to perform a task using shell script. I am new to awk programming and any help would be greatly appreciated. I have the following 3 files (for example) file1: Name count Symbol chr1_1_50 10 XXXX chr3_101_150 30 YYYY File2: Name ... (13 Replies)
Discussion started by: Diya123
13 Replies

4. Shell Programming and Scripting

Counting words

Hi Is there a way to count the no. of words in all files in directory. All are text files.I use wc -w but somehow i am not getting the rite answer. Is there an alternative. Thanks in advance (9 Replies)
Discussion started by: kinny
9 Replies

5. UNIX for Dummies Questions & Answers

counting words

if i have a long list of data, with every line beginning with an ip-address, like this: 62.165.8.187 - - "GET /bestandnaam.html HTTP/1.1" 200 5848 "http://www.domeinnaam.nl/bestandnaam.html" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)" how do i count which ip-adresses are mentioned... (3 Replies)
Discussion started by: FOBoy
3 Replies

6. Shell Programming and Scripting

Counting

Hi, I want to count how many rows are in a file for a specific column. eg. K NM K NM K NM K JK K NM K JK K NM so the file is tab-delimited. I want to count how many rows are in column 2 and how many NMs there are. I used awk awk '{OFS="\t"}; {count++} {print i,... (3 Replies)
Discussion started by: phil_heath
3 Replies

7. Shell Programming and Scripting

Counting up a variable

Hello, I am trying to write a shell script, but i encountered a problem I cant solve alone so I hope you guys can help me. The situation is: I have a script file and a config file, in my config file I set some Variables: for example: destination=(xp, xq, xt) username=testor... (3 Replies)
Discussion started by: Kenada
3 Replies

8. IP Networking

counting the packets

there are a number of clients connected to a server.... how can i count that each clients recieve ...? how do i moniter the activity of the client..? (2 Replies)
Discussion started by: damn_bkb
2 Replies

9. Shell Programming and Scripting

Help with counting files please

Hi all. If I have a unix directory with multiple files, lets say, I have some with .dat extensions, some with .txt extensions, etc etc. How in a script would I provide a count of all the different file types (so, the different extensions, I guess) in the directory?? So if I had: test.dat... (6 Replies)
Discussion started by: gerard1
6 Replies
Login or Register to Ask a Question