Compare Data in the same file


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Compare Data in the same file
# 1  
Old 10-13-2005
Question Compare Data in the same file

Dear Unix-Gurus,

I'm trying to write a script to compare the data in a log file. Here's how my logfile will look like:

'List All A0 Data in Destination Server'
A0567
A0678
A0789
List A0 Files in Source Server
A0567
A0678
A0789

So if the file match in Source Server match Destination Server, I will issue a rm command to remove the file fromthe Source Server.

I have included a nawk command in my script which is something like this:

nawk '/^A0/' test.log > A0_Output.log

and it gives me the following output:

more A0_Output.log
A0567
A0678
A0789
A0567
A0678
A0789

So how can I compare the data inside A0_output.log? I'm kinda lost now... Smilie

Anyone can provide me with some solutions please?

Thanks.

lweegp

Last edited by lweegp; 10-13-2005 at 03:45 AM..
# 2  
Old 10-17-2005
Quote:
Originally Posted by lweegp
So how can I compare the data inside A0_output.log?
Compare it with what ?

Try diff.

vino
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Compare 2 files and extract the data which is present in other file - awk is not working

file2 content f1file2 content f1,1,2,3,4,5 f1,2,4,6,8,10 f10,1,2,3,4,5 f10,2,4,6,8,10 f5,1,2,3,4,5 f5,2,4,6,8,10awk 'FNR==NR{a;next}; !($1 in a)' file2 file1output f10,1,2,3,4,5 f10,2,4,6,8,10 f5,1,2,3,4,5 f5,2,4,6,8,10awk 'FNR==NR{a;next}; ($1 in a)' file2 file1output nothing... (4 Replies)
Discussion started by: gksenthilkumar
4 Replies

2. Shell Programming and Scripting

Compare data with reference from other file

Gents, Please can you help with this. I have a big file (file2) which contends many records increment every 25 rows ( column 1 ). Then I have other file as reference (file1).. column 1 to 11. I want to compare that all values in file2 (column 2 to 12.) match with values in... (2 Replies)
Discussion started by: jiam912
2 Replies

3. Shell Programming and Scripting

Compare the source definition file with data file

Hi How to compare the source definition file in unix with the data file . Please can you share me example if some one has done it before (3 Replies)
Discussion started by: Raj4fusion
3 Replies

4. Shell Programming and Scripting

Compare two files and write data to second file using awk

Hi Guys, I wanted to compare a delimited file and positional file, for a particular key files and if it matches then append the positional file with some data. Example: Delimited File -------------- Byer;Amy;NONE1;A5218257;E5218257 Byer;Amy;NONE1;A5218260;E5218260 Positional File... (3 Replies)
Discussion started by: Ajay Venkatesan
3 Replies

5. Shell Programming and Scripting

Compare 2 text file with 1 column in each file and write mismatch data to 3rd file

Hi, I need to compare 2 text files with around 60000 rows and 1 column. I need to compare these and write the mismatch data to 3rd file. File1 - file2 = file3 wc -l file1.txt 58112 wc -l file2.txt 55260 head -5 file1.txt 101214200123 101214700300 101250030067 101214100500... (10 Replies)
Discussion started by: Divya Nochiyil
10 Replies

6. Shell Programming and Scripting

compare 2 files and extract the data which is not present in other file with condition

I have 2 files whose data's are as follows : fileA 00 lieferungen 00 attractiop 01 done 02 forness 03 rasp 04 alwaysisng 04 funny 05 done1 fileB alwayssng dkhf fdgdfg dfgdg sdjkgkdfjg funny rasp (7 Replies)
Discussion started by: rajniman
7 Replies

7. Shell Programming and Scripting

Compare a file with all others then print off data

my script so far nawk -F, 'NR==FNR{a++;next} a{b++} END{for(i in b){if(b-1){print i";\t\t"b}else{print "NEW:"i";\t\t1"} } }' OFS=, 20111228.csv *.csv | sort NE:221478,SHELF:13,SLOT:4; 2 NE:221726,SHELF:8,SLOT:1; 2 NE:222318,SHELF:14,SLOT:1; 9... (20 Replies)
Discussion started by: llcooljatt
20 Replies

8. Shell Programming and Scripting

help to compare data from file using shell script to c++ program

hello ....i am new in shell script..I have one shell script which read inputs from file...and second is c++ pgm..i call my script from c++ programm..to compare file values to c++ pgm value.. our shell script is shubhi.sh #! /bin/sh while read line do echo -e"$line" done<file1 this script... (1 Reply)
Discussion started by: shubhig15
1 Replies

9. Shell Programming and Scripting

Compare and print out data only appear in file 1 problem

Below is the data content of file_1 and file_2: file_1 >sample_1 FKGJGPOPOPOQA ASDADWEEWERE ASDAWEWQWRW ASDASDASDASDD file_2 >sample_1 DRTOWPFPOPOQA ASDADWEEASDF ASDADRTYWRW ASDASDASDASDD I got try the following perl script. Unfortunately, it can't give my desired output result... (7 Replies)
Discussion started by: patrick87
7 Replies

10. Shell Programming and Scripting

Compare data in 2 files and delete if file exist

Hi there, I have written a script called "compare" (see below) to make comparison between 2 files namely test_put.log and Output_A0.log #!/bin/ksh while read file do found="no" while read line do echo $line | grep $file > /dev/null if then echo $file found found="yes" break fi... (3 Replies)
Discussion started by: lweegp
3 Replies
Login or Register to Ask a Question