Get the distinct of a particular field


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Get the distinct of a particular field
# 1  
Old 04-26-2012
Get the distinct of a particular field

From the below ps output , I want the distinct values of the third field (ie. I need the distinct PPIDs)
Code:
$ ps -ef
     UID      PID     PPID   C    STIME    TTY  TIME CMD
    root        1        0   0   Nov 10      - 48:49 /etc/init 
    root  1769576        1   0   Nov 10      -  0:07 /usr/lib/errdemon 
    root  2162910  3080252   0   Nov 10      -  4:25 /usr/sbin/xntpd 
    root  2490396  3080252   0   Nov 10      -  0:12 /usr/sbin/inetd 
    root  2556110        1   0   Nov 10      -  0:39 /usr/sbin/emcp_xcryptd -d 
  oracle  2883682        1   0 22:55:57      -  0:00 oracleukcocs (LOCAL=NO) 
    root  3080252        1   0   Nov 10      -  0:00 /usr/sbin/srcmstr 
    root  3473642  3080252   0   Nov 10      -  0:00 /usr/sbin/biod 6 
    root  3539058        1   0   Nov 10      -  0:00 /opt/VRTSpbx/bin/pbx_exchange 
    root  3604714  3080252   0   Nov 10      -  0:00 /usr/sbin/portmap 
    root  3670090        1   0   Nov 10      - 215:04 /opt/CA/eTrustAudit/bin//acactmgr -start 
    root  3735774  3080252   0   Nov 10      -  0:00 /usr/sbin/rpc.lockd -d 0 
    root  3866788        1   0   Nov 10      - 61:01 /opt/ecc/exec/MAR610/maragent 
    root  3932170  4259856   0   Nov 10      - 78:25 /opt/tivoli/ep/_jvm/jre/bin/java -Xmx384m 
    root  3997698        1   0   Nov 10      - 89:28 /opt/ecc/exec/mstragent 
    root  4063464        1   0   Nov 10      -  0:01 /opt/edagent/bin/discagnt 
  oracle  4128852        1   0   Nov 10      - 18:15 ora_pmon_cetcnd 
    root  4194544        1   0   Nov 10      -  2:38 /usr/sbin/cron 
    root  4259856        1   0   Nov 10      -  1:09 bin/nonstop_aix @config/nonstop.properties 
    root  4390994  4784380   0   Nov 10      -  0:04 /pvcs/dim10/serena/dimensions/10.1/cm/prog/dmpool.x 3 
 maestro  4456682        1   0   Nov 10      -  1:12 /maestro/tws/bin/netman 
    root  4653090  3080252   0   Nov 10      -  0:00 /usr/sbin/rsct/bin/IBM.DRMd 
    root  4784380        1   0   Nov 10      -  0:00 ./dmlsnr -param /pvcs/dim10/serena
  oracle  4849792        1   0   Nov 10      - 18:24 ora_pmon_keval 
    root  4915212        1   0   Nov 10      - 47:01 /usr/bin/topasrec  -L -s 300 -R 1 -r 6 -o /etc/perf
  oracle  4980776        1   0   Mar 23      - 10:37 ora_mmon_cecmcr 
    root  5111818  3080252   0   Nov 10      -  5:46 /usr/sbin/rsct/bin/rmcd -a IBM.LPCommands -r 
 nn62517  5177524  9830630   0   Apr 17 pts/28  0:00 /bin/ksh /var/security/login/bin/Rsh.ksh 
  oracle  5374064        1   0   Nov 10      - 16:06 ora_vktm_orcl 
  oracle  5439514        1   0 14:24:46      -  0:00 oraclematm (LOCAL=NO) 
  oracle  5505058        1   0   Nov 10      -  3:57 ora_dbrm_orcl 
    root  5570636  3080252   0   Nov 10      -  0:01 /usr/sbin/rsct/bin/vac8/IBM.CSMAgentRMd 
  oracle  5636188        1   0   Nov 10      -  3:37 ora_mman_cetcnd 
    root  5767220  3080252   0   Nov 10      -  0:00 /usr/sbin/rsct/bin/IBM.ServiceRMd 
  oracle  5963944        1   0   Nov 10      -  6:41 ora_dbw0_orcl 
  oracle  6160552        1   0   Nov 10      - 14:06 ora_psp0_cecocc 
  oracle  6225996        1   0   Nov 10      -  5:16 /optware/oracle/11g/SIT/db/bin/tnslsnr lsnrcecocr -inherit 
  oracle  6291464        1   0 22:55:59      -  0:00 oracleukcocs (LOCAL=NO) 
  oracle  6553680        1   0   Nov 10      -  4:54 /optware/oracle/11g/SIT/db/bin/tnslsnr lsnrceboas -inherit 
    root  6619232  9502920   0   Nov 10      - 26:59 /opt/SSHtectia/libexec/ssh-servant-g3 --slave 
  oracle  6684754        1   0   Nov 10      -  5:20 /optware/oracle/11g/SIT/db/bin/tnslsnr lsnrukcocs -inherit 
    root  6750298  9502920   0   Nov 10      - 30:54 /opt/SSHtectia/libexec/ssh-servant-g3 --slave 
  oracle  6881384        1   0   Nov 10      -  5:54 /optware/oracle/11g/SIT/db/bin/tnslsnr lsnrrucocs -inherit 
  oracle  7012462        1   0   Nov 10      - 125:42 ora_dia0_emurss 
  oracle  7078002        1   0 22:39:51      -  0:00 oracleaecocs (LOCAL=NO) 
  oracle  7274610        1   0   Nov 10      - 25:21 ora_pmon_orcl 
 vm73587  7340282  9830630   0 13:43:26 pts/31  0:00 -ksh

Any idea how I can do this?
# 2  
Old 04-26-2012
Code:
sort -u -n -k3,3 infile

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Get distinct value in bash between two string

Sorry for my english i am french So i am receiving from a script this prompt : tabular;critical;mirroring;DG INTlocaldg VOLUME appears tabular;critical;mirroring;DG INTlocaldg VOLUME bh3vm tabular;critical;mirroring;DG INTlocaldg VOLUME dev tabular;critical;mirroring;DG INTlocaldg VOLUME... (3 Replies)
Discussion started by: cterra
3 Replies

2. UNIX for Dummies Questions & Answers

Distinct filenames pattern

Hi All, I am working on designing the archival process for my system, where I will have to find distinct file names ( when excluded time_stamp extention ) from given directory and for each file type keep the latest and move all other older to different location ( lets say dir Back ). Below are... (2 Replies)
Discussion started by: freakabhi
2 Replies

3. Shell Programming and Scripting

Command to identify distinct field value

Could anyone help me on a command to identify distinct values from a particular column ?my input file has header. So i need a command in which we pass Column1 as parameter. For eg my input is like Column1 Column2 Column3 ... (4 Replies)
Discussion started by: krish123
4 Replies

4. Shell Programming and Scripting

Need the distinct of these lines

Red Hat Enterprise Linux 5.4 I have a text file (error log file) , which has occurences of an error message like ORA-01652: unable to extend temp segment by 8 in tablespace xxxxxThere are around 3000 error messages like this in the error log file. But there are only 7 or 8 distinct... (3 Replies)
Discussion started by: John K
3 Replies

5. Shell Programming and Scripting

Find distinct values

Hi, I have two files of the following format file1 chr1:345-456 chr2:123-456 chr2:455-678 chr3:456-789 chr3:444-555 file2 chr1:345-456 chr2:123-456 chr3:456-789 output (2 Replies)
Discussion started by: jacobs.smith
2 Replies

6. UNIX for Dummies Questions & Answers

Grep distinct

Hello, I have a file which looks like: %_SPE_RDP_NUM_ECH(7)*************% %_SPE_RDP_NUM_ECH(70)************% %_SPE_RDP_NUM_ECH(71)************% %_SPE_RDP_NUM_ECH(72)************% %_SPE_RDP_NUM_ECH(8)*************% %_SPE_RDP_NUM_ECH(9)*************% %_SPE_FLUXPREV_PRES1_MT_HT(2)****%... (5 Replies)
Discussion started by: mvalonso
5 Replies

7. Web Development

SQL - Distinct plus more

Hi all, I have an interesting and I am sure simple question for yau'll. Basically this is what I am after: The table: CREATE TABLE places (id INT, city VARCHAR(24), name VARCHAR(24)); The data: id = 1, city = canberra, name = aaron id = 2, city = canberra, name = andrew id = 3, city... (4 Replies)
Discussion started by: STOIE
4 Replies

8. Shell Programming and Scripting

grep distinct values

this is a little more complex than that. I have a text file and I need to find all the distinct words that appear in a line after the word TABLESPACE when I grep for just the word tablespace, I get: how do i parse this a little better so i have a smaller file to read? This is just an... (4 Replies)
Discussion started by: guessingo
4 Replies

9. Shell Programming and Scripting

Getting Distinct values from second field in a file....

Hi I have a pipe delimited file. I am trying to grab the DISTINCT value from the second field. The file is something like: 1233|apple|ron 1234|apple|elephant 1235|egg|man the output I am trying to get from second field is apple,egg (apple coming only once) Thanks simi (4 Replies)
Discussion started by: simi28
4 Replies

10. UNIX for Dummies Questions & Answers

how to pick distinct records..........

How can i pick distinct records which consists of duplicate data from a ASCII file using UNIX commands (3 Replies)
Discussion started by: ss4u
3 Replies
Login or Register to Ask a Question