Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Shell script needed for comparing two files Post 302954224 by surender reddy on Saturday 5th of September 2015 05:19:26 PM
Old 09-05-2015
Shell script needed for comparing two files

Hi,

I need shell script to compare the two files based on certain fields and output should contains the required fields based on result.pls find sample input files and required output

file 1
HTML Code:
COUNT, BNG_IP,PORT,OVLAN
    22 ,  10.238.60.129,1/1,2009
    144 ,  10.238.60.129,1/1,2251
      3 ,  10.238.60.129,1/1,2255
     48 ,  10.238.60.129,1/1,2294
     32 ,  10.238.60.129,1/1,2677
    137 ,  10.238.60.129,1/1,2682
     49 ,  10.238.60.129,1/1,2683
     17 ,  10.238.60.129,1/1,2684
    123 ,  10.238.60.129,1/1,2686
     74 ,  10.238.60.129,1/1,2731
      8 ,  10.238.60.129,1/1,2896
     39 ,  10.238.60.129,2/1,2002
      8 ,  10.238.60.129,2/1,2310
      9 ,  10.238.60.129,2/1,2312
      4 ,  10.238.60.129,2/1,2313
     13 ,  10.238.60.129,2/1,2314
      1 ,  10.238.60.129,2/1,2316
File 2
HTML Code:
  BNG_IP DSLAM_IP PORT 
10.238.60.129 , 10.232.0.9 , 1/1 , 2009:124
10.238.60.129 , 10.232.2.2 , 2/1 , 2302:122
10.238.60.129 , 10.232.2.3 , 2/1 , 2303:122
10.238.60.129 , 10.232.2.4 , 2/1 , 2304:122
10.238.60.129 , 10.232.2.6 , 2/1 , 2306:122
10.238.60.129 , 10.232.2.7 , 2/1 , 2307:122
10.238.60.129 , 10.232.2.8 , 2/1 , 2308:122
10.238.60.129 , 10.232.2.9 , 2/1 , 2309:122
10.238.60.129 , 10.232.2.10 , 2/1 , 2310:122
10.238.60.129 , 10.232.2.11 , 2/1 , 2311:122
10.238.60.129 , 10.232.2.12 , 2/1 , 2312:122
10.238.60.129 , 10.232.2.13 , 2/1 , 2313:122
10.238.60.129 , 10.232.2.16 , 2/1 , 2316:122
10.238.60.129 , 10.232.2.17 , 2/1 , 2317:122
10.238.60.129 , 10.232.2.18 , 2/1 , 2318:122
Script should compare the first file with second file for BNG_IP,PORT,OVLAN fields if its available in file 2 .it should give the corresponding DSLAM_IP from file2
Required out put will be as below

Output
HTML Code:
COUNT, BNG_IP,PORT,OVLAN,DSLAM_IP
 22 ,  10.238.60.129,1/1,2009 ,10.232.0.9
 8 ,  10.238.60.129,2/1,2310,10.232.2.10
  9 ,  10.238.60.129,2/1,2312,10.232.2.12
  4 ,  10.238.60.129,2/1,2313,10.232.2.13
 1 ,  10.238.60.129,2/1,2316,10.232.2.16

Last edited by surender reddy; 09-05-2015 at 06:24 PM..
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

shell script comparing files in a file

There is a text file that contains the data in the following format: COLUMN1 COLUMN2 ABC 1 ABC 2 ABC 3 DEF 4 DEF 5 XYZ 7 We have to create a second text file... (4 Replies)
Discussion started by: raina_nalin
4 Replies

2. UNIX for Dummies Questions & Answers

shell script for comparing 2 files

Hi, how to read the 2 files and compare each other in shell script? i have 2 files test1 and test2, both files contains 20 character records.we have to compare file 1 records with file2, if exists then reject the record else we have to append it to test2 file. in file test1 around 100 single... (2 Replies)
Discussion started by: prashanth.spl
2 Replies

3. Shell Programming and Scripting

comparing two files using shell script

hi experts please help me to compare two files which are in different directory file1<file will be master file> (/home/rev/mas.txt} ex x1 x2 file2 <will be in different folder> (/home/rev/per/.....) ex x3 x4 the filesinside per folder i need to compare with master file and the files... (2 Replies)
Discussion started by: revenna
2 Replies

4. Shell Programming and Scripting

help needed in a shell script for printing files

Hi All, I am writing a shell script to print all the files in a particular folder. This script is on solaris server . I am using the lp command to send the requests . lp -d printername filename . The output I get is the request id. Is there any way I can use the request Id to determine if... (1 Reply)
Discussion started by: shahshilpa
1 Replies

5. Shell Programming and Scripting

Shell Script Needed to Read a text from a list files

Hi, Below is my issue which I desperately need and I want a shell script which can do this job. I need this script as I m planning to put this for a system health check. Please assist me. 1. There are 10 log files in a particular location. 2. open each log file. Goto to the end of the... (4 Replies)
Discussion started by: kashriram
4 Replies

6. Shell Programming and Scripting

comparing 2 files in shell script

I have 2 files config1h.txt ----------------- BFMU=ENABLE,ID=PM THR=OFF,REP=ALL,CON=IACM,TIM=OFF;GPON collection strategy 1.3.6.1.2.1.2.2:8 1.3.6.1.2.1.2.2:7 1.3.6.1.4.1.637.61.1.35.11.4:4 1.3.6.1.4.1.637.61.1.35.11.4:3 1.3.6.1.4.1.637.61.1.35.10.1:2 1.3.6.1.4.1.637.61.1.35.10.1:43... (7 Replies)
Discussion started by: LavanyaP
7 Replies

7. Shell Programming and Scripting

Comparing 2 files using shell script

Hi Experts, I have 2 files 1 file consists of 800 records and 2 file consists of 100 records with matching column as Membership_Num.So i need a script which will compare the 2 files and displays the output.As these are the files the script should take any delimter like (tab,comma) as input... (6 Replies)
Discussion started by: naveen.dasu
6 Replies

8. Shell Programming and Scripting

shell script for comparing two files

Hi, I have 2 files as below FILE1.dat co1|co2|co3 abnd|45.56|AZ dkny|30.2|PA sam|.23|VA FILE.CTL FILENAME|FILE1.dat NO OF RECORDS|3 CHECKSUM|75.99 Could you please help me to write a shell script to compare 1. TOTAL RECORDS from FILE1.dat with NO of RECORDS in FILE.CTL 2.... (8 Replies)
Discussion started by: dreamsportsteam
8 Replies

9. Shell Programming and Scripting

Need Help in comparing 2 text files in shell script

Hi All, I have 2 files like below vi f1 frog elephant rabit zebra dog vi f2 rabit dog ============== Now i want to comapre two files and the result will be frog (8 Replies)
Discussion started by: kumar85shiv
8 Replies
SOCKD.ROUTE(5)							File Formats Manual						    SOCKD.ROUTE(5)

NAME
sockd.route - Route file for multi-homed SOCKS proxy server SYNOPSIS
/etc/sockd.route DESCRIPTION
The file /etc/sockd.route is used by the SOCKS server program sockd to determine which of its network interfaces it should use to reach a given destination host. It is needed only if your SOCKS server host is multi-homed and your version of sockd supports RBIND. A multi-homed host is a host with more than one network interfaces and with its IP_FORWARDING turned off. Only the multi-homed version of sockd can be run on such hosts. You can find out the version of your sockd (or rsockd) by command sockd -ver or rsockd -ver A line in the file can be up to 1024 characters long. Lines starting with a `#' are comments. Non-comment lines must be of the form if_addr dst_addr dst_mask All three fields are required and are separated by spaces or tabs. Each filed is specified in the usual dotted form of IP addresses, e.g., 128.23.16.2. if_addr must be the IP address of one of the network interfaces on the SOCKS server host. dst_addr specifies either the IP address of a host, a network, or a subnet in the usual dotted form, e.g., 129.201.4.0, or a domain name, e.g., internic.net. dst_mask spec- ifies mask for the IP address used in dst_addr. Bits in dst_mask that are set to 0 indicate the bit positions to be ignored during compar- ison of IP addresses. So, specifying 255.255.255.255 in dst_mask demands an exact match with dst_addr, whereas 0.0.0.0 in dst_mask causes a matching with any given destination address regardless of what is specified for dst_addr. If a domain name is used for dst_addr, the con- tents of dst_mask are ignored, though it must still be supplied (simply use 0.0.0.0). If the domain name starts with a period, it speci- fies a zone and matches all domain names within that zone, otherwise it matches only the domain name itself. For example, xyz.com matches only xyz.comP, while .xyz.com macthes not only xyz.com, but also abc.xyz.com and this.and.that.xyz.com, among others. The special symbol ALL (which must be entirely in uppercase) matches everything. Domain names are otherwise case-insentive. When using a domain name in dst_addr, you have be very careful in maintaining your DNS setup. See the last few paragraphs in sockd.conf(5). When a multi-homed sockd receives a network request, it first checks with /etc/sockd.fc (or /etc/sockd.conf) to decide whether the request should be allowed or denied. For an allowable request, sockd then checks the given destination IP address or domain name against the dst_addr dst_mask pair in /etc/sockd.route, one line at a line. Once a match is found, the network interface of the corresponding if_addr field is used for connection to the destination host. Remaining lines in the file are skipped. Therefore the order of the lines in the file is of extreme importance. If no match is found throughout the file, a line indicating the error is produced using syslog with facility daemon and level err and the request is ignored. You have the option of using the frozen route file /etc/sockd.fr instead of /etc/sockd.route. The frosen file is produced by make_sockdfr and is essentially the memory image of the parsed route file. Using it can reduce the start-up delay of the SOCKS server since it eliminate the need for parsing. Since the SOCKS server always looks for /etc/sockd.fr first, be sure that you always run make_sockdfr every time after you modifify /etc/sockd.route. EXAMPLES
Suppose you have a dual-homed host with interface 129.1.2.3 connecting to your internal Class B network 129.1, and interface 129.1.254.1 connecting to the outside world. If you only use the SOCKS server to provide connections to outside hosts, then the file /etc/sockd.route only needs one line: 129.1.254.1 0.0.0.0 0.0.0.0 If you also use the SOCKS server to provide connection to internal hosts as well, then two lines would suffice: 129.1.2.3 129.1.0.0 255.255.0.0 129.1.254.1 0.0.0.0 0.0.0.0 Note that these two lines must be in the order given above. If you prefer using domain name instead, the lines should be 129.1.2.3 .myown.com 0.0.0.0 129.1.254.1 0.0.0.0 0.0.0.0 assuming that myown.com is your domain. SEE ALSO
dump_sockdfr(8), make_sockdfr(8), sockd(8), sockd.fr(5) May 6, 1996 SOCKD.ROUTE(5)
All times are GMT -4. The time now is 08:37 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy