Sponsored Content
Top Forums Shell Programming and Scripting How to compare two column using awk? Post 303003269 by RavinderSingh13 on Monday 11th of September 2017 12:08:02 PM
Old 09-11-2017
Hello shanul karim,

Welcome to forums, I hope you will enjoy learning and sharing knowledge here. Could you please try following and let me know if this helps you.
Code:
awk -F, '{split($2,a," ");if(a[1]==$3){print $0,"Matched"} else {print $0,"Non-Matched"}}'   Input_file

Output will be as follows.
Code:
UDC_MSISDN,UDC_NPREFIX STG_MSISDN,STG_IMSI_NPREFIX Non-Matched
466000000000000,1545 466000000000000,820011902457295 Non-Matched
466000000100,1545 466000000100,820011001002929 Non-Matched
466000000101,1545 466000000101,820011001002927 Non-Matched
466000000201,1545 466000000201,820011001002951 Non-Matched
466000000300,1545 466000000300,820011001002950 Non-Matched
466000000301,1545 466000000301,820011001002955 Non-Matched
466500066972,1479 466500066972,1479 Matched
466500066977,1735 466500066977,1735 Matched
466500066980,1479 466500066980,1479 Matched
466500066981,1479 466500066981,1479 Matched
466500066987,1479 466500066987,1479 Matched
466500067002,1479 466500067002,1479 Matched
466500067006,1479 466500067006,1479 Matched

Thanks,
R. Singh

Last edited by hicksd8; 04-26-2020 at 08:29 AM..
This User Gave Thanks to RavinderSingh13 For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk compare column between 2 files

Hi, I would like to compare file1 and file2 file1 1 2 3 file2 1 a 2 b 3 c 4 d The result should only print out "d" in file 2. Thanks (3 Replies)
Discussion started by: phamp008
3 Replies

2. Shell Programming and Scripting

awk column compare

I've been banging my head against the wall to accomplish the following. Given two files: File a.txt 12345 hello 32324 there File b.txt 12345 stuff 45454 howdy 32324 joe If column 1 matches between the two files, then print only the entire line of the 2nd file (b.txt in this... (3 Replies)
Discussion started by: tiggyboo
3 Replies

3. Shell Programming and Scripting

awk compare column with date format

I have this code to compare columns 1 and 10 between file1 and file 2 and give me all records that match column 1 but dont match column 10 However column 10 is date format mm/dd/yy and awk cant read it and compare ...i tried awk < file1 -F~ '{print $10}' and it gave blank screen Is... (1 Reply)
Discussion started by: sigh2010
1 Replies

4. Shell Programming and Scripting

awk arrays - compare value in second column to variable

Hello, I am trying to redirect files to a directory by using a config file. The config files is as such: xxxxxx,ID,PathToDirectory xxxxxx,ID2,PathToDirectory2 and so on... I have a variable that should match one of these IDs. I want to load this config file into an awk array, and... (2 Replies)
Discussion started by: jrfiol
2 Replies

5. Shell Programming and Scripting

awk compare column n replace with in one file

hi Friends need to compare columns in one file where the data looks like below laptop,IBM phone,samsung car,rental user1,laptop user2,laptop user3,phone want to get output as laptop,IBM phone,samsung car,rental user1,IBM user2,IBM user3,samsung need to seach $2 in array of $1 and... (4 Replies)
Discussion started by: arun1401
4 Replies

6. Shell Programming and Scripting

Compare the second column of a file with the second column of another in awk

Hi, I know that this topic has been discussed in the past and I've tried to follow all the guidelines. Anyhow, I following describe my problem. I have a file (file1 , no. records = 67) containing pairs of IP addresses as follows (with single space as delimiter between the fields): example... (5 Replies)
Discussion started by: amarn
5 Replies

7. Shell Programming and Scripting

How to compare the values of a column in a same file using awk?

Dear Unix experts, I have got a file where I would like to compare the values of second column if first column is same in such a way that the difference between the values is >50. If not, I would like to discard both values. For example, my input file looks like - comp275_c0_seq2 73... (7 Replies)
Discussion started by: utritala
7 Replies

8. UNIX for Dummies Questions & Answers

awk command to compare files by column

So I have this issue. I have 4 files. the first one is the master file who has all possible combinations: file 1 - a - b - c - d - e the other three have some of the letters and a number instead of - for example file 2 34 a 5 c file 3 10 b 12 ... (3 Replies)
Discussion started by: Quijotes
3 Replies

9. Shell Programming and Scripting

Need help on awk to compare only integer on particular column

Hi, 0.23 2.94% 0.00 0.00% 17.8G 55.7% 19.6G 40.9% 630 0.00% 0.06 0.77% - - 7524M 22.9% 15.6G 32.6% - - From the above sample output. I need to compare whether the 6th field is more than 10G..if so print the entire line. Here the 6th field is memory TIA (5 Replies)
Discussion started by: Sumanthsv
5 Replies

10. Shell Programming and Scripting

Need awk or Shell script to compare Column-1 of two different CSV files and print if column-1 matche

Example: I have files in below format file 1: zxc,133,joe@example.com cst,222,xyz@example1.com File 2 Contains: hxd hcd jws zxc cst File 1 has 50000 lines and file 2 has around 30000 lines : Expected Output has to be : hxd hcd jws (5 Replies)
Discussion started by: TestPractice
5 Replies
condor_status(1)					      General Commands Manual						  condor_status(1)

Name
       condor_status Display - status of the Condor pool

Synopsis
       condor_status [-debug] [help options] [query options] [display options] [custom options] [name ... ]

Description
       condor_status  is  a  versatile	tool  that  may  be used to monitor and query the Condor pool. The condor_status tool can be used to query
       resource information, submitter information, checkpoint server information, and daemon master information. The specific query sent and  the
       resulting information display is controlled by the query options supplied. Queries and display formats can also be customized.

       The options that may be supplied to condor_statusbelong to five groups:

	  * Help optionsprovide information about the condor_status tool.

	  * Query optionscontrol the content and presentation of status information.

	  * Display optionscontrol the display of the queried information.

	  * Custom optionsallow the user to customize query and display information.

	  * Host optionsspecify specific machines to be queried

       At any time, only one help option, one query optionand one custom optionmay be specified. Any number of customand host optionsmay be speci-
       fied.

Options
       -debug

	  Causes debugging information to be sent to  stderr , based on the value of the configuration variable  TOOL_DEBUG

       -help

	  (Help option) Display usage information

       -diagnose

	  (Help option) Print out query ClassAd without performing query

       -absent

	  (Query option) Query for and display only absent resources.

       -any

	  (Query option) Query all ClassAds and display their type, target type, and name

       -avail

	  (Query option) Query condor_startdClassAds and identify resources which are available

       -ckptsrvr

	  (Query option) Query condor_ckpt_serverClassAds and display checkpoint server attributes

       -claimed

	  (Query option) Query condor_startdClassAds and print information about claimed resources

       -cod

	  (Query option) Display only machine ClassAds that have COD claims. Information displayed includes the claim ID, the owner of the  claim,
	  and the state of the COD claim.

       -collector

	  (Query option) Query condor_collectorClassAds and display attributes

       -direct hostname

	  (Query option) Go directly to the given host name to get the ClassAds to display

       -java

	  (Query option) Display only Java-capable resources.

       -license

	  (Query option) Display license attributes.

       -master

	  (Query option) Query condor_masterClassAds and display daemon master attributes

       -negotiator

	  (Query option) Query condor_negotiatorClassAds and display attributes

       -pool centralmanagerhostname[:portnumber]

	  (Query  option)  Query  the  specified central manager using an optional port number. condor_status queries the machine specified by the
	  configuration variable  COLLECTOR_HOST by default.

       -run

	  (Query option) Display information about machines currently running jobs.

       -schedd

	  (Query option) Query condor_scheddClassAds and display attributes

       -server

	  (Query option) Query condor_startdClassAds and display resource attributes

       -startd

	  (Query option) Query condor_startdClassAds

       -state

	  (Query option) Query condor_startdClassAds and display resource state information

       -statistics WhichStatistics

	  (Query option) Can only be used if the -directoption has been specified. Identifies which Statistics attributes to include in the  Clas-
	  sAd. WhichStatisticsis specified using the same syntax as defined for  STATISTICS_TO_PUBLISH . See the definition at	3.3.11for details.

       -storage

	  (Query option) Display attributes of machines with network storage resources.

       -submitters

	  (Query option) Query ClassAds sent by submitters and display important submitter attributes

       -subsystem type

	  (Query  option)  If typeis one of collector, negotiator, master, schedd, startd, or quill, then behavior is the same as the query option
	  without the -subsystemoption. For example, -subsystem collectoris the same as -collector. A value of typeof CkptServer, Machine, Daemon-
	  Master, or Schedulertargets that type of ClassAd.

       -vm

	  (Query  option)  Query condor_startdClassAds, and display only VM-enabled machines. Information displayed includes the the machine name,
	  the virtual machine software version, the state of machine, the virtual machine memory, and the type of networking.

       -attributes Attr1[,Attr2 ... ]

	  (Display option) Explicitly list the attributes in a comma separated list which should be displayed when using the -xmlor  -longoptions.
	  Limiting the number of attributes increases the efficiency of the query.

       -expert

	  (Display option) Display shortened error messages

       -long

	  (Display option) Display entire ClassAds (same as -verbose)

       -sort expr

	  (Display  option)  Change  the display order to be based on ascending values of an evaluated expression given by expr. Evaluated expres-
	  sions of a string type are in a case insensitive alphabetical order. If multiple -sortarguments appear on the command line, the  primary
	  sort will be on the leftmost one within the command line, and it is numbered 0. A secondary sort will be based on the second expression,
	  and it is numbered 1. For informational or debugging purposes, the ClassAd output to be displayed will appear as if the ClassAd had  two
	  additional  attributes.   CondorStatusSortKeyExpr<N> is the expression, where  <N> is replaced by the number of the sort.  CondorStatus-
	  SortKey<N> gives the result of evaluating the sort expression that is numbered  <N> .

       -total

	  (Display option) Display totals only

       -verbose

	  (Display option) Display entire ClassAds. Implies that totals will not be displayed.

       -xml

	  (Display option) Display entire ClassAds, in XML format. The XML format is fully defined  at	http://www.cs.wisc.edu/condor/classad/ref-
	  man/.

       -constraint const

	  (Custom option) Add constraint expression. See section 4.1and section 4.1.4for details on ClassAds and on writing expressions.

       -format fmt attr

	  (Custom option) Display attribute or expression attrin format fmt. To display the attribute or expression the format must contain a sin-
	  gle  printf(3) -style conversion specifier. Attributes must be from the resource ClassAd. Expressions are ClassAd  expressions  and  may
	  refer  to  attributes in the resource ClassAd. If the attribute is not present in a given ClassAd and cannot be parsed as an expression,
	  then the format option will be silently skipped. The conversion specifier must match the type of the	attribute  or  expression.  %s	is
	  suitable  for  strings  such as  Name , %d for integers such as  LastHeardFrom , and %f for floating point numbers such as  LoadAvg . %v
	  identifies the type of the attribute, and then prints the value in an appropriate format. %V identifies the type of the  attribute,  and
	  then	prints	the  value  in	an appropriate format as it would appear in the -longformat. As an example, strings used with %V will have
	  quote marks. An incorrect format will result in undefined behavior. Do not use more than one conversion specifier  in  a  given  format.
	  More	than  one  conversion specifier will result in undefined behavior. To output multiple attributes repeat the -formatoption once for
	  each desired attribute. Like	printf(3) -style formats, one may include other text that will be reproduced directly.	A  format  without
	  any conversion specifiers may be specified, but an attribute is still required. Include n to specify a line break.

General Remarks
	  *  The  default  output  from  condor_status is formatted to be human readable, not script readable. In an effort to make the output fit
	  within 80 characters, values in some fields might be truncated. Furthermore, the Condor Project can (and does) change the formatting	of
	  this	default  output as we see fit. Therefore, any script that is attempting to parse data from condor_status is strongly encouraged to
	  use the -formatoption (described above).

	  * The information obtained from condor_startdand condor_schedddaemons may sometimes appear to be inconsistent. This is normal since con-
	  dor_startdand  condor_schedddaemons  update  the Condor manager at different rates, and since there is a delay as information propagates
	  through the network and the system.

	  * Note that the  ActivityTime in the	Idle state is notthe amount of time that the machine has  been	idle.  See  the  section  on  con-
	  dor_startdstates in the Administrator's Manualfor more information.

	  *  When  using condor_status on a pool with SMP machines, you can either provide the host name, in which case you will get back informa-
	  tion about all slots that are represented on that host, or you can list specific slots by name. See the examples below for details.

	  * If you specify host names, without domains, Condor will automatically try to resolve those host names into fully qualified host  names
	  for you. This also works when specifying specific nodes of an SMP machine. In this case, everything after the ``@'' sign is treated as a
	  host name and that is what is resolved.

	  * You can use the -directoption in conjunction with almost any other set of options. However, at this time, the only	daemon	that  will
	  allow  direct  queries for its ad(s) is the condor_startd. So, the only options currently not supported with -directare -scheddand -mas-
	  ter. Most other options use startd ads for their information, so they work seamlessly  with  -direct.  The  only  other  restriction	on
	  -directis  that  you may only use 1 -directoption at a time. If you want to query information directly from multiple hosts, you must run
	  condor_status multiple times.

	  * Unless you use the local host name with -direct, condor_status will still have to contact a collector to find the  address	where  the
	  specified  daemon  is listening. So, using a -pooloption in conjunction with -directjust tells condor_status which collector to query to
	  find the address of the daemon you want. The information actually displayed will still be retrieved directly from the daemon you  speci-
	  fied as the argument to -direct.

Examples
       Example 1To view information from all nodes of an SMP machine, use only the host name. For example, if you had a 4-CPU machine, named  vul-
       ture.cs.wisc.edu , you might see

       % condor_status	vulture

       Name		  OpSys      Arch   State     Activity LoadAv Mem   ActvtyTime

       slot1@vulture.cs.w LINUX      INTEL  Claimed   Busy     1.050   512  0+01:47:42
       slot2@vulture.cs.w LINUX      INTEL  Claimed   Busy     1.000   512  0+01:48:19
       slot3@vulture.cs.w LINUX      INTEL  Unclaimed Idle     0.070   512  1+11:05:32
       slot4@vulture.cs.w LINUX      INTEL  Unclaimed Idle     0.000   512  1+11:05:34

			   Total Owner Claimed Unclaimed Matched Preempting Backfill

	       INTEL/LINUX     4     0	     2	       2       0	  0	   0

		     Total     4     0	     2	       2       0	  0	   0

       Example 2To view information from a specific nodes of an SMP machine, specify the node directly. You do this by providing the name  of  the
       slot. This has the form	slot#@hostname . For example:

       % condor_status	slot3@vulture

       Name		  OpSys      Arch   State     Activity LoadAv Mem   ActvtyTime

       slot3@vulture.cs.w LINUX      INTEL  Unclaimed Idle     0.070   512  1+11:10:32

			   Total Owner Claimed Unclaimed Matched Preempting Backfill

	       INTEL/LINUX     1     0	     0	       1       0	  0	   0

		     Total     1     0	     0	       1       0	  0	   0

       Constraint option examples

       Further explanation and examples are in section .

       The Unix command to use the constraint option to see all machines with the  OpSys of  "LINUX" :

       % condor_status	-constraint OpSys=="LINUX"

       Note that quotation marks must be escaped with the backslash characters for most shells.

       The Windows command to do the same thing:

       >condor_status  -constraint " OpSys==""LINUX"" "

       Note that quotation marks are used to delimit the single argument which is the expression, and the quotation marks that identify the string
       must be escaped by using a set of two double quote marks without any intervening spaces.

       To see all machines that are currently in the Idle state, the Unix command is

       % condor_status	-constraint State=="Idle"

       To see all machines that are bench marked to have a MIPS rating of more than 750, the Unix command is

       % condor_status	-constraint 'Mips>750'

       -cod option example

       The -codoption displays the status of COD claims within a given Condor pool.

       Name	   ID	ClaimState TimeInState RemoteUser JobId Keyword
       astro.cs.wi COD1 Idle	    0+00:00:04 wright
       chopin.cs.w COD1 Running     0+00:02:05 wright	  3.0	fractgen
       chopin.cs.w COD2 Suspended   0+00:10:21 wright	  4.0	fractgen

		     Total  Idle  Running  Suspended  Vacating	Killing
       INTEL/LINUX	 3     1	1	   1	     0	      0
	     Total	 3     1	1	   1	     0	      0

Exit Status
       condor_statuswill exit with a status value of 0 (zero) upon success, and it will exit with the value 1 (one) upon failure.

Author
       Condor Team, University of Wisconsin-Madison

Copyright
       Copyright (C) 1990-2012 Condor Team, Computer Sciences Department, University of  Wisconsin-Madison,  Madison,  WI.  All  Rights  Reserved.
       Licensed under the Apache License, Version 2.0.

       See the Condor Version 7.8.2 Manualor http://www.condorproject.org/licensefor additional notices. condor-admin@cs.wisc.edu

								  September 2012						  condor_status(1)
All times are GMT -4. The time now is 10:10 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy