Sponsored Content
Top Forums Shell Programming and Scripting Match columns and print specific field Post 302924203 by Pushpraj on Friday 7th of November 2014 01:06:26 AM
Old 11-07-2014
Match columns and print specific field

Hello,

I have data in following format.
Code:
pxname,svname,qcur,qmax,scur,smax,slim,stot,bin,bout,dreq,dresp,ereq,econ,eresp,wretr,wredis,status,weight,act,bck,chkfail,chkdown,lastchg,downtime,qlimit,pid,iid,sid,throttle,lbtot,tracked,type,rate,rate_lim,rate_max,check_status,check_code,check_duration,hrsp_1xx,hrsp_2xx,hrsp_3xx,hrsp_4xx,hrsp_5xx,hrsp_other,hanafail,req_rate,req_rate_max,req_tot,cli_abrt,srv_abrt,

main,FRONTEND,,,0,3,15000,61,13752,14647,0,0,1,,,,,OPEN,,,,,,,,,1,1,0,,,,0,0,0,12,,,,0,60,0,1,0,0,,0,12,61,,,
apache2,elb0,0,0,0,1,,3,687,723,,0,,0,0,0,0,UP,1,1,0,0,0,45,0,,1,2,1,,3,,2,0,,1,L4OK,,0,0,3,0,0,0,0,0,,,,0,0,
apache2,elb1,0,0,0,1,,3,687,723,,0,,0,0,0,0,UP,1,1,0,0,0,45,0,,1,2,2,,3,,2,0,,1,L4OK,,0,0,3,0,0,0,0,0,,,,0,0,
apache2,elb2,0,0,0,1,,3,687,723,,0,,0,0,0,0,UP,1,1,0,0,0,45,0,,1,2,3,,3,,2,0,,1,L4OK,,0,0,3,0,0,0,0,0,,,,0,0,
apache2,elb3,0,0,0,1,,3,687,723,,0,,0,0,0,0,UP,1,1,0,0,0,45,0,,1,2,4,,3,,2,0,,1,L4OK,,0,0,3,0,0,0,0,0,,,,0,0,
apache2,elb4,0,0,0,1,,3,687,723,,0,,0,0,0,0,UP,1,1,0,0,0,45,0,,1,2,5,,3,,2,0,,1,L4OK,,0,0,3,0,0,0,0,0,,,,0,0,
apache2,BACKEND,0,0,0,3,0,60,13752,14460,0,0,,0,0,0,0,UP,24,24,0,,0,45,0,,1,2,0,,60,,1,0,,12,,,,0,60,0,0,0,0,,,,,0,0,

Now I want to print "slim" value for "main,FRONTEND" or "ereq" value for "apache2,elb4" or process data in similar fashion. I tried below command but it prints entire column.
Code:
#awk -F, '/main,FRONTEND/{print}' socat.txt

it prints entire line which has around 51 fields, among that one value carries "slim" field value.I dont know field number of "slim". I want to print "slim" value of "main,FRONTEND" column. Giving field number to awk can work but since there are lots of fields and elbs I dont want to use that option.

Thanks,
Pushpraj

Last edited by Franklin52; 11-07-2014 at 06:59 AM.. Reason: Please use code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Print last occurrence if first field match

Hi All, I have an input below. If the term in the 1st column is equal, print the last row which 1st column is equal.In the below example, it's " 0001 k= 27 " and " 0004 k= 6 " (depicted in bold). Those terms in 1st column which are not repetitive are to be printed as well. Can any body help me... (9 Replies)
Discussion started by: Raynon
9 Replies

2. Shell Programming and Scripting

Script to Match first field of two Files and print

Hi, I want to get script or command in Sun Unix which matches first fields of both the files and print the feilds of one files, example may make it more clear. InputFile1 ================== Alex,1,fgh Menthos,45454,toto Gothica,855,ee Zenie4,77,gg Salvatore,66,oo Dhin,1234,papapa... (3 Replies)
Discussion started by: indian.ace
3 Replies

3. Shell Programming and Scripting

Match and print columns in second file

Hi All, I have to match each row in file 1 with 1st row in file 2 and print the corresponding column from file2. I am trying to use an awk script to do this. For example cat File1 X1 X3 X4 cat File2 ID X1 X2 X3 X4 A 1 6 2 1 B 2 7 3 3 C 3 8 4 1 D 4 9 1 1 (3 Replies)
Discussion started by: newpro
3 Replies

4. UNIX for Dummies Questions & Answers

Match columns and write specific word

Hi all I have another question as of now. I have two files One file contain data like this Serendipity glamerus Shenpurity In another file these entries are present in different columns like this from 2 column onwards SRN Serendipity Non serendipity ... (1 Reply)
Discussion started by: Priyanka Chopra
1 Replies

5. UNIX for Dummies Questions & Answers

How to match on phrase at beginning of line and specific columns?

Here is my file: 700 7912345678910 61234567891234567891 700 8012345678910 61234567891234567891 I want to pull all lines that begin with '700' only if columns 11-12 are '79'. My code so far only pulls the '79', not the whole line: grep ^700 file1 | cut -c 11,12 |... (7 Replies)
Discussion started by: Scottie1954
7 Replies

6. Shell Programming and Scripting

Match two columns from two files and print output

Hello, I have two files which are of the following format File 1 which has two columns Protein_ID Substitution NP_997239 T53R NP_060668 V267M NP_058515 P856A NP_001206 T55M NP_006601 D371Y ... (2 Replies)
Discussion started by: nans
2 Replies

7. Shell Programming and Scripting

How to print with awk specific field different from specific character?

Hello, i need help with awk. I have this file: cat number DirB port 67 er_enc_out 0 er_bad_os 0 DirB port 71 er_enc_out 56 er_bad_os 0 DirB port 74 er_enc_out 0 er_bad_os 0 DirB port 75 ... (4 Replies)
Discussion started by: elilmal
4 Replies

8. UNIX for Advanced & Expert Users

Match and print based on columns

HI, I have 2 different questions in this thread. Consider 2 files as input (input file have different line count ) File 1 1 1 625 56 1 12 657 34 1 9 25 45 1 2 20 54 67 3 25 35 27 4 45 73 36 5 125 56 45 File2 1 1 878 76 1 9 83 67 2 20 73 78 4 47 22 17 3 25 67 99 (4 Replies)
Discussion started by: rossi
4 Replies

9. Shell Programming and Scripting

Command/script to match a field and print the next field of each line in a file.

Hello, I have a text file in the below format: Source Destination State Lag Status CQA02W2K12pl:D:\CAQA ... (10 Replies)
Discussion started by: pocodot
10 Replies

10. Shell Programming and Scripting

awk to print text in field if match and range is met

In the awk below I am trying to match the value in $4 of file1 with the split value from $4 in file2. I store the value of $4 in file1 in A and the split value (using the _ for the split) in array. I then strore the value in $2 as min, the value in $3 as max, and the value in $1 as chr. If A is... (6 Replies)
Discussion started by: cmccabe
6 Replies
A2ENCONF(8)						      System Manager's Manual						       A2ENCONF(8)

NAME
a2enconf, a2disconf - enable or disable an apache2 configuration file SYNOPSIS
a2enconf [ [-q|--quiet] configuration] a2disconf [ [-q|--quiet] configuration] DESCRIPTION
This manual page documents briefly the a2enconf and a2disconf commands. a2enconf is a script that enables the specified configuration file within the apache2 configuration. It does this by creating symlinks within /etc/apache2/conf-enabled. Likewise, a2disconf disables a specific configuration part by removing those symlinks. It is not an error to enable a configuration which is already enabled, or to disable one which is already disabled. Note that many configuration file may have a dependency to specific modules. Unlike module dependencies, these are not resolved automati- cally. Configuration fragments stored in the conf-available directory are considered non-essential or being installed and manged by reverse dependencies (e.g. web scripts). OPTIONS
-q, --quiet Don't show informative messages. -m, --maintmode Enables the maintainer mode, that is the program invocation is effectuated automatically by a maintainer script. This switch should not be used by end users. -p, --purge When disabling a module, purge all traces of the module in the internal state data base. EXIT STATUS
a2enconf and a2disconf exit with status 0 if all configurations are processed successfully, 1 if errors occur, 2 if an invalid option was used. EXAMPLES
a2enconf security a2disconf charset Enables Apache security directives stored in the security configuration files, and disables the charset configuration. FILES
/etc/apache2/conf-available Directory with files giving information on available configuration files. /etc/apache2/conf-enabled Directory with links to the files in conf-available for enabled configuration files. SEE ALSO
apache2ctl(8), a2enmod(8), a2dismod(8). AUTHOR
This manual page was written by Arno Toell <debian@toell.net> for the Debian GNU/Linux distribution, as it is a Debian-specific script with the package. 14 February 2012 A2ENCONF(8)
All times are GMT -4. The time now is 11:47 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy