Sponsored Content
Top Forums Shell Programming and Scripting comparing files with field using awk Post 302437123 by raghavendra.cse on Wednesday 14th of July 2010 05:06:01 AM
Old 07-14-2010
comparing files with field using awk

hi,

i have 1 files a.csv temp.out

a.cvs looks like
Code:
add,16390,180,674X,HALIFAX_COMMONS_X,902,497,902-209
add,16390,180,674X,HALIFAX_COMMONS_X,902,497,902-219
add,16390,180,674X,HALIFAX_COMMONS_X,902,497,902-220
add,16390,180,674X,HALIFAX_COMMONS_X,902,497,902-221

and temp.out looks like

Code:
902,497,902,209,1003,1003,HALIFAX NS
902,497,902,219,1003,1003,HALIFAX NS
902,497,902,220,1003,1003,HALIFAX NS
902,497,902,221,1003,1003,HALIFAX NS

if 6,7,8,9 th filed of a.csv matches with 1,2,3,4 of temp.out then output should looks like

Code:
add,16390,180,674X,HALIFAX_COMMONS_X,902,497,902-219,1003,1003,HALIFAX NS
add,16390,180,674X,HALIFAX_COMMONS_X,902,497,902-220,1003,1003,HALIFAX NS
add,16390,180,674X,HALIFAX_COMMONS_X,902,497,902-221,1003,1003,HALIFAX NS


i am working with awk script but is unable to compare the four fileds ?

---------- Post updated at 04:04 AM ---------- Previous update was at 04:02 AM ----------

i am sorry output shold olooks like as below(that was mistake)
add,16390,180,674X,HALIFAX_COMMONS_X,902,497,902,219,1003,1003,HALIFAX NS
add,16390,180,674X,HALIFAX_COMMONS_X,902,497,902,220,1003,1003,HALIFAX NS
add,16390,180,674X,HALIFAX_COMMONS_X,902,497,902,221,1003,1003,HALIFAX NS

---------- Post updated at 04:06 AM ---------- Previous update was at 04:04 AM ----------

sorry a.csv file looks like as below

add,16390,180,674X,HALIFAX_COMMONS_X,902,497,902,209
add,16390,180,674X,HALIFAX_COMMONS_X,902,497,902,219
add,16390,180,674X,HALIFAX_COMMONS_X,902,497,902,220
add,16390,180,674X,HALIFAX_COMMONS_X,902,497,902,221


both input and output are comma seperated
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

comparing two files using awk.

Hi All, a new bie to awk, How to compare substring of col1,file 1 with col2file2 and get file1contents+col3file2 as output. file1 ----- kumarfghh,23,12000,5000 rajakumar,24,14000,2500 rajeshchauhan,25,16000,2600 manoj,26,17000,2300 file 2 -------- 123,kumar,US, 123,sukumar,UK... (4 Replies)
Discussion started by: jerome Sukumar
4 Replies

2. Shell Programming and Scripting

Last field problem while comparing two csv files

Hi All, I've two .csv files as below file1.csv abc, tdf, 223, tpx jgsd, tex, 342, rpy a, jdjdsd, 423, djfkld Where as file2.csv is the new version of file1.csv with some added fields in the end of each line and some additional lines. lfj, eru, 98, jkldj, 39, jdkj9 abc, tdf, 223, tpx,... (3 Replies)
Discussion started by: ganapati
3 Replies

3. Shell Programming and Scripting

Field comparing in files

Guys trying to compare field in two files. For Ex: demo.txt 23.33.4.2 hostname 3.2.4.2 hostname12 demo1.txt 3.3.3.3 hostname23 45.23.23.23 hostname 323 I would like to compare the ips b/w these two files.any... (2 Replies)
Discussion started by: coolkid
2 Replies

4. Shell Programming and Scripting

Comparing two huge files on field basis.

Hi all, I have two large files and i want a field by field comparison for each record in it. All fields are tab seperated. file1: Email SELVAKUMAR RAMACHANDRAN Email SHILPA SAHU Web NIYATI SONI Web NIYATI SONI Email VIINII DOSHI Web RAJNISH KUMAR Web ... (4 Replies)
Discussion started by: Suman Singh
4 Replies

5. UNIX for Advanced & Expert Users

Comparing two files using awk

i have one file say file1 having many records.Each record contains 2000 characters.i have to compare 192-200 (stored as name)characters in this file from other file say file2 having name stored in 1-9 characters. after comparing i have to print the record from file1 in another file say file3 ... (3 Replies)
Discussion started by: sonam273
3 Replies

6. Shell Programming and Scripting

comparing 2 files with awk

Hi, I'm a new user in awk and i'm trying to compare two files to create a third one if some values match in both files. The first file has this content: s 45.960746365 _21_ AGT 2490 [21:0 22:0 s 45.980418496 _21_ AGT 2491 [21:0 22:0 s 46.000090627 _21_ AGT 2492 [21:0 22:0 s 47.906552206... (2 Replies)
Discussion started by: carlosoria
2 Replies

7. Shell Programming and Scripting

Comparing the matches in two files using awk when both files have their own field separators

I've two files with data like below: file1.txt: AAA,Apples,123 BBB,Bananas,124 CCC,Carrot,125 file2.txt: Store1|AAA|123|11 Store2|BBB|124|23 Store3|CCC|125|57 Store4|DDD|126|38 So,the field separator in file1.txt is a comma and in file2.txt,it is | Now,the output should be... (2 Replies)
Discussion started by: asyed
2 Replies

8. Shell Programming and Scripting

AWK: Pattern match between 2 files, then compare a field in file1 as > or < field in file2

First, thanks for the help in previous posts... couldn't have gotten where I am now without it! So here is what I have, I use AWK to match $1 and $2 as 1 string in file1 to $1 and $2 as 1 string in file2. Now I'm wondering if I can extend this AWK command to incorporate the following: If $1... (4 Replies)
Discussion started by: right_coaster
4 Replies

9. Shell Programming and Scripting

awk for comparing two files

so have file1 like this: joe 123 jane 456 and then file2 like this: 123 left right 456 up down joe ding dong jane flip flop what I need to do is compare col1 and col2 in file1 with col1 in file2 and generate a new file that has lines like this: joe 123 ding dong left right jane... (11 Replies)
Discussion started by: Jaymz
11 Replies

10. Shell Programming and Scripting

Comparing two files field and position

I have two files : file1 and file2 file1 format: 7026-H70 7026-1017685 7026-H70 7026-1017687 7026-B80 7026-108D65A 7026-B80 7026-108D67A 7046-B50 7026-1034B4A File2 format : mt01cp01 7026-B80 01108D69A mt01cp02 7026-B80 01108D68A mt01sv01 7046-B50... (7 Replies)
Discussion started by: amir07
7 Replies
DACS_AUTOLOGIN_SSL(8)					     DACS Web Services Manual					     DACS_AUTOLOGIN_SSL(8)

NAME
dacs_autologin_ssl - use an SSL client certificate to automatically obtain DACS credentials SYNOPSIS
dacs_autologin_ssl [dacsoptions[1]] DESCRIPTION
This program is part of the DACS suite. The dacs_autologin_ssl CGI program, in conjunction with appropriate DACS configuration and a valid SSL client certificate, can be used for user-transparent DACS authentication. A user is not prompted for a username or password, and no user-visible sign-on procedure takes place. At present, the program merely acts as glue to indirectly invoke dacs_authenticate(8)[2]. Any valid X.509 certificate can be used for this purpose, including a self-signed certificate. Please refer to the OpenSSL[3] documentation for additional information about certificates. This program can be used to automatically and transparently authenticate a user that has been issued an SSL client certificate. When an unauthenticated user is denied access to a DACS-wrapped resource, she can be automatically authenticated and redirected back to the resource without any user input or action. This assumes that the client certificate is sent automatically by the browser and that no additional user prompting is needed by the authenticating jurisdiction. For redirection to the original resource to work properly. the original request must have used the GET method. Note The cert style of authentication must be configured when dacs_autologin_ssl is being used as described. See dacs_authenticate(8)[4]. OPTIONS
Only the standard dacsoptions[1] command line arguments are recognized. Web Service Arguments dasc_autologin_ssl understands the following CGI arguments. DACS_ERROR_URL When dacs_autologin_ssl is invoked as a result of DACS event handling, DACS_ERROR_URL is automatically passed to it by dacs_acs(8)[5] and represents the original URL to which access was denied. In typical use, dacs_autologin_ssl is configured as the handler for a dacs_acs 902 error code (NO_AUTH, "Authentication by DACS is required"). dacs_autologin_ssl then invokes dacs_authenticate. If DACS authentication is successful, dacs_authenticate ordinarily issues a browser redirect to the value of DACS_ERROR_URL and a cookie bearing the credentials are set in the browser (but see the NOREDIRECT argument). This argument is optional; if not provided, the jurisdiction's configured post-authentication action will occur. NOREDIRECT If this optional argument is present (its value is immaterial), dacs_autologin_ssl instructs dacs_authenticate to not issue a browser redirect to the value of DACS_ERROR_URL. AUTH_JURISDICTION If this optional argument is present, it gives the name of the jurisdiction at which authentication should take place. By default, dacs_authenticate is invoked at the same jurisdiction as dacs_autologin_ssl. CERT_NAME_ATTR This optional argument explicitly names the attribute in the certificate from which to set USERNAME. The default value is SSL_CLIENT_S_DN_CN. It is an error if the specified attribute name does not exist. Giving the value of CERT_NAME_ATTR as the empty string results in the empty string being passed as the value of USERNAME. EXAMPLE
A typical use of dacs_autologin_ssl is to transparently authenticate a user via his SSL client certificate. In the DACS configuration file, dacs.conf, jurisdiction EXAMPLE is configured as follows (this excerpt from a configuration file uses fictitious domain names): <Jurisdiction uri="example.com"> JURISDICTION_NAME "EXAMPLE" ACS_ERROR_HANDLER "NO_AUTH https://example.com/cgi-bin/dacs/dacs_autologin_ssl" <!-- Authenticate using an SSL certificate. --> <Auth id="cert"> URL "https://example.com/cgi-bin/dacs/local_cert_authenticate" STYLE "cert" CONTROL "sufficient" CERT_CA_PATH "/usr/local/apache2.2/conf/ssl.crt" CERT_NAME_ATTR "SSL_CLIENT_S_DN_CN" </Auth> </Jurisdiction> Assume the following access control rule applies to the request: <acl_rule status="enabled"> <services> <service url_pattern='/foo.html'/> </services> <rule order="allow,deny"> <allow> user("auth") </allow> </rule> </acl_rule> The preceding configuration results in the following behaviour. An unauthenticated user accessing foo.html (https://example.com/foo.html) is denied access because the rule governing that web page tests for authentication and no credentials are sent with the request. As a result, the ACS_ERROR_HANDLER[6] directive causes the user to be redirected to dacs_autologin_ssl, which redirects the user to dacs_authenticate, passing arguments as necessary. dacs_authenticate then invokes local_cert_authenticate[4], passing it the client's certificate. The certificate is validated and a username is extracted from it and mapped to a valid DACS username. If authentication succeeds, DACS credentials for the jurisdiction EXAMPLE are generated. These credentials are returned to the browser within a cookie and the browser is redirected to the value of DACS_ERROR_URL (recall that DACS_ERROR_URL was passed to dacs_autologin_ssl by dacs_acs when the 902 handler was invoked and was forwarded to dacs_authenticate). In this example the user is redirected to https://example.com/foo.html. Given the rule above, this time the user's request for foo.html will be granted. dacs_autologin_ssl may also be used as the target of an explicit authentication link. For example: <a href="https://example.com/cgi-bin/dacs/dacs_autologin_ssl? AUTH_JURISDICTION=EXAMPLE& DACS_ERROR_URL=https://example.com/cgi-bin/dacs/dacs_current_credentials">Login</a> Following the link should result in the user being authenticated and redirected to the specified URL. DIAGNOSTICS
The program exits 0 if everything was fine, 1 if an error occurred. SEE ALSO
dacs_authenticate(8)[2], dacs_acs(8)[5], dacs.conf(5)[7], autologin(8)[8] AUTHOR
Distributed Systems Software (www.dss.ca[9]) COPYING
Copyright2003-2012 Distributed Systems Software. See the LICENSE[10] file that accompanies the distribution for licensing information. NOTES
1. dacsoptions http://dacs.dss.ca/man/dacs.1.html#dacsoptions 2. dacs_authenticate(8) http://dacs.dss.ca/man/dacs_authenticate.8.html 3. OpenSSL http://www.openssl.org 4. dacs_authenticate(8) http://dacs.dss.ca/man/dacs_authenticate.8.html#local_cert_authenticate 5. dacs_acs(8) http://dacs.dss.ca/man/dacs_acs.8.html 6. ACS_ERROR_HANDLER http://dacs.dss.ca/man/dacs.conf.5.html#ACS_ERROR_HANDLER 7. dacs.conf(5) http://dacs.dss.ca/man/dacs.conf.5.html 8. autologin(8) http://dacs.dss.ca/man/autologin.8.html 9. www.dss.ca http://www.dss.ca 10. LICENSE http://dacs.dss.ca/man/../misc/LICENSE DACS 1.4.27b 10/22/2012 DACS_AUTOLOGIN_SSL(8)
All times are GMT -4. The time now is 08:35 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy