eleminate repated process names and get second column value


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting eleminate repated process names and get second column value
# 1  
Old 01-01-2009
Lightbulb eleminate repated process names and get second column value

i want shell script who can eliminate those repeated process and get value of top process of second column.

Mark with red one only i want other repeated process should be eliminate but how? Help me out guys.


oracle 496094
oracle 471572
oracle 471497
oracle 470561
ko9coll 96157
kuxagent 91252
shlap64 90914
koragent 90591
koragent 90450
ko9coll 90372
tnslsnr 90203
stat_daemon 90196
kux_vmstat 89484
ifstat 89436
nfs_stat 89402
kddsignl 88875
kddsignl 88875
ibmdiradmn 88437
# 2  
Old 01-01-2009
Try:

Code:
awk '{ if(a[$1]=="") {a[$1]=$2; print $1" "a[$1]; } }'  filename

# 3  
Old 01-01-2009
Code:
awk '!x[$1]++' filename

# 4  
Old 01-02-2009
Code:
#! /usr/bin/perl
open FH,"<a.txt";
while(<FH>){
	my @tmp=split(" ",$_);
	if(! exists $hash{$tmp[0]}){
		print $_;
		$hash{$tmp[0]}++;
	}
}
close FH;

# 5  
Old 01-02-2009
Idea:
See if your "ps" command has the "-H" (hierarchy) option .
Beware:
1) unix does not necessarily allocate process IDs in numeric order.
2) I have not noticed a process hierarchy with Oracle. On my system the parent process PPID for all Oracle processes is ID 1 (init). Yours may be different.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sorting a column according to the number of names

Hey, So I'm having issues sorting a data set. The data set contains entries as such; # key: sex, time, athlete, athlete's nationality, date, city, country M, 2:30:57.6, Harry Payne, GBR, 1929-07-05, Stamford Bridge, England M, 2:5:42, Khalid Khannouchi, MAR, 1999-10-24, Chicago, USA M,... (1 Reply)
Discussion started by: DNM_UKN
1 Replies

2. UNIX for Dummies Questions & Answers

How to get column names?

Hi Everybody, if i give below ps -ef cmnd with user id as cly to search i'll get the output as below dev52:home/k9087cly->ps -ef |grep cly s0998cly 50228 472666 1 23:10:52 pts/7 0:00 ps -ef s0998cly 141746 237722 0 22:57:52 pts/6 0:00 ssh isp1.6705 s0998cly 161596 186422 2 ... (3 Replies)
Discussion started by: Ramanareddygv
3 Replies

3. Programming

Serching process names

#include <stdio.h> #include <string.h> int main(void) { char buf; int transcount=0, elapsetotal=0; while(!feof(stdin)) { int newoluf=0, elapsetime=-1; char timestamp={0}; buf='\0'; // Blank out... (2 Replies)
Discussion started by: sena
2 Replies

4. Shell Programming and Scripting

Transpose field names from column headers to values in one column

Hi All, I'm looking for a script which can transpose field names from column headers to values in one column. for example, the input is: IDa;IDb;IDc;PARAM1;PARAM2;PARAM3; a;b;c;p1val;p2val;p3val; d;e;f;p4val;p5val;p6val; g;h;i;p7val;p8val;p9val; into the output like this: ... (6 Replies)
Discussion started by: popesk
6 Replies

5. Shell Programming and Scripting

How to set column names?

data: For the code below, it extracts info from two files and stores it in outfile. For the ouput file i want to mention some column names like this, So where i can mention in the script to get outfile with code: nawk -F\| 'NR==FNR{n=int($2); a=$2; next}a{print a FS $2}' SC.lis ext.fmt >... (3 Replies)
Discussion started by: Diddy
3 Replies

6. Shell Programming and Scripting

rearrange the column names with comma as column delimiter

Hi, I am new to shell scripting, i have requirement can any one help me out in this regrads, in directory i have file like invoice1.txt, invoice2.txt in each file i have fixed number of columns, 62 in number but they are randomly arranged.like for first file invoice1.txt can have columns... (5 Replies)
Discussion started by: madhav62
5 Replies

7. Shell Programming and Scripting

Change names in a column based on the symbols in another column

If the 4th column has - sign then the names in 3rd column has to change to some user defined names (as shown in output). Thanx input1 1 a aaaaa + 2 b bbbbb + 3 c ccccc + 4 d ddddd + 5 e eeeee + 6 f xxxxx + 8 h hhhhh +... (8 Replies)
Discussion started by: repinementer
8 Replies

8. UNIX for Dummies Questions & Answers

Process id's in file names

Hello, I am editing a script which has a .sh extension but is listed as #! /bin/ksh that has output files where process ID's are somehow getting tacked onto the end of the filename. The programmer codes these scripts as "/tmp/email_file$$" saying that he put the $$ in there to be able to handle... (1 Reply)
Discussion started by: tekster757
1 Replies

9. UNIX for Dummies Questions & Answers

Displaying VERY long process names with ps -ef

Hi, I'm trying to display all process on an AIX server with the string SLRServer in them. Normally "ps -ef|grep SLRServer" would be sufficient, however in this instance the process name is enormous and the part which contains this string has been truncated, as you can see in the example below ... (8 Replies)
Discussion started by: m223464
8 Replies

10. Shell Programming and Scripting

Column names in flat files

Hi all, I want to create column names in a flat file and then load the data through some other application. For example, I have a file with emp.txt and I need column names as eno,ename,sal in the first line. The delimiter here is comma and record delimiter is end of line or unix new line. Could... (1 Reply)
Discussion started by: srivsn
1 Replies
Login or Register to Ask a Question