Comparing to 3 data


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Comparing to 3 data
# 1  
Old 05-13-2015
Comparing to 3 data

Code:
# cat list.txt
server1
server2
server3
server4

# data to be compared of.
#dns address
1.1.1.1

2.2.2.2

3.3.3.3


#for i in `cat list.txt`
do
grep dns $ i
done

Desired output:
Code:
#cat server1|grep dns
1.2.3.4

Then it will send an email that dns is different, not equal to 1.1.1.1 , 2.2.2.2 and 3.3.3.3

---------- Post updated at 10:52 PM ---------- Previous update was at 10:20 PM ----------

done,,we may clsed this
# 2  
Old 05-13-2015
This is not clear and vague. At a guess you have a number of files, server1, server3, and server4.
File list.txt is a list of these files.

This part isn't clear, but it seems you have another file containing ip addresses, let's call this file valid_addresses.txt.

So file list.txt contains
server1
server3
server4

File valid_addresses.txt contains...
1.1.1.1
2.2.2.2
3.3.3.3

Let's say file server1 contains...
4.4.4.4

Let's say file server3 contains
3.3.3.3

Let's say file server4 contains
2.2.2.2

Then this script x.sh works...
Code:
 #! /bin/ksh 
for i in `cat list.txt`  
do         
    ip=`cat ${i}`        
    if ! grep -q "${ip}" valid_addresses.txt          
    then                  
       echo "DNS IP ${ip} from file ${i} not found in valid_addresses.txt"           
    fi 
done

If you are using bash shell,
change top to !# /bin/bash

and if you want to email
change echo statement to something like...
Code:
 
echo "DNS IP ${ip} from file ${i} not found in valid_addresses.txt" | mailx -s "subject" someuser@host


Last edited by blackrageous; 05-13-2015 at 02:37 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Comparing Data file with Crtl file

Hi, I need to compare a file with its contents matching to that of another file(filename , received date and record count). Lets say has File A original data Ex - 1,abc,1234 2,bcd,4567 3,cde,8901 and File B has details of File A Ex- FILEA.TXT|06/17|2010|3 (filename)|(received... (18 Replies)
Discussion started by: Prashanth B
18 Replies

2. UNIX for Dummies Questions & Answers

Comparing lines of data

Total UNIX Rookie, but I'm learning. I have columns of integer data separated by spaces, and I'm using a Mac terminal. What I want to do: 1. Compare "line 1 column 2" (x) to "line 2 column 2" (y); is y-x>=100? 2. If yes, display difference and y's line number 3. If no, increment x and y by... (9 Replies)
Discussion started by: markymarkg123
9 Replies

3. Shell Programming and Scripting

Comparing the data in a 2 files

Hi Friends, I have a file 1 CREATE MULTISET TABLE TEYT_Q9_T.TEST ,NO FALLBACK , NO BEFORE JOURNAL, NO AFTER JOURNAL, CHECKSUM = DEFAULT, DEFAULT MERGEBLOCKRATIO ( XYZ DECIMAL(10,0), ABC VARCHAR(5) CHARACTER SET LATIN NOT CASESPECIFIC, PQR... (3 Replies)
Discussion started by: i150371485
3 Replies

4. Shell Programming and Scripting

Retrieve data from one file comparing the ID in the second file

Hi all, I have one file with IDs Q8NDM7 P0C1S8 Q8TF30 Q9BRP8 O00258 Q6AWC2 Q9ULE0 Q702N8 A4UGR9 Q13426 Q6P2D8 Q9ULM3 A8MXQ7 I want to compare ID file with another file which has complete information about these IDs and also about other IDs which are not in the above ID file. As... (10 Replies)
Discussion started by: kaav06
10 Replies

5. Shell Programming and Scripting

Shell script for comparing data of tables

Hi, I have two databases with same tables on different servers.I need to check the data content in each table and if something is missing, should print that. I have a tool which takes the snapshot the table structure,index so on and compares with the other server tables snapshot. Now i need... (1 Reply)
Discussion started by: nessj
1 Replies

6. Shell Programming and Scripting

Comparing data inside file

Hi Everyone, I will try to explain my question please forgive my english here. I am looking for shell script or command that can compare data in the files. I have 50 files in one directory test1 test2 test3 ....so on. I want to compare data in each files with each other and output each... (4 Replies)
Discussion started by: email-lalit
4 Replies

7. Shell Programming and Scripting

comparing scalars contaning "DOUBLE QUOTES" as data

Hello to all, Does anyone know the solution ? Two strings A and B are present. I want to check whether B is a Substring of A. 1. The value of A is - 29 * * * /bin/ls "test" "tmp*" "log*" (Note: Pl note that A contains DOUBLEQUOTES, ASTERISK & FRONTSLASH) 2. The value of B is -... (5 Replies)
Discussion started by: rssrik
5 Replies

8. Shell Programming and Scripting

Comparing data in file with values in table

Hi, I want to calculate the number of pipe delimiters in a file for all lines seperately. For eg:i have a file Project.txt Mohit|chawla|123|678 File1|File2|345|767|678 And my file contains many lines like this it shd give me the output as 4 5 or give me the output for all the... (0 Replies)
Discussion started by: Mohit623
0 Replies

9. Shell Programming and Scripting

Problem comparing 2 files with lot of data

Hello everyone, here's the scenario I have two files, each one has around 1,300,000 lines and each line has a column (phone numbers). I have to get the phones that are in file1 but not in file2. I can get these phones trough Oracle but my boss does not want that so he gave me the files with the... (4 Replies)
Discussion started by: rafisha
4 Replies

10. UNIX for Dummies Questions & Answers

Comparing data list...

I have a list of files that I want to compare to another list of files, how do I do that? The first list will be my known list and hard coded, for example: mylist="janfile.tar jarfile.jar jan.rpt.Z" etc. The second list will be found by doing an 'ls' piped to a file: ls > filelist.dat ... (4 Replies)
Discussion started by: giannicello
4 Replies
Login or Register to Ask a Question