compare & print lines with 2 requirements


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting compare & print lines with 2 requirements
# 1  
Old 03-14-2012
compare & print lines with 2 requirements

1.compare 90 logs >20 print off with correct figure
2.compare latest log i.e ciscoresets_20120314 against all records not just the 90 (as above) and any lines not matching print as:

NEW:SYDGRE04,10,9 1

(note this number could be 2 or whatever not necessary 1 it could be 2,3 or even 10 as ciscoresets_20120314 file could have seen this line multiple times where as no other file has, if you understand logic)

**must also take into account the count of the latest file i.e ciscoresets_20120314

sample logs...

ciscoresets_20120314
ciscoresets_20120313
ciscoresets_20120312
ciscoresets_20120311
ciscoresets_20120310

cat ciscoresets_20120314
SYDGRE04,10,9
SYDGRE04,10,10
SYDGRE04,10,11
SYDGRE04,10,12
SYDGRE04,10,13
SYDGRE04,10,14
SYDGRE04,10,15
NEPGRE01,10,1
NEPGRE01,10,2
NEPGRE01,10,3
NEPGRE01,10,4
NEPGRE01,10,5
NEPGRE01,10,6
NEPGRE01,10,7
NEPGRE01,10,8
NEPGRE01,10,9
NEPGRE01,10,10
NEPGRE01,10,11
NEPGRE01,10,12
NEPGRE01,10,13
NEPGRE01,10,14
NEPGRE01,10,15
NEPGRE01,10,16


cat ciscoresets_20120313
SYDGRE04,10,1
SYDGRE04,10,2
SYDGRE04,10,3
SYDGRE04,10,4
SYDGRE04,10,5
SYDGRE04,10,6
SYDGRE04,10,7
SYDGRE04,10,8
SYDGRE04,10,9
SYDGRE04,10,10
SYDGRE04,10,11
SYDGRE04,10,12
SYDGRE04,10,13
SYDGRE04,10,14
SYDGRE04,10,15
NEPGRE01,10,4
NEPGRE01,10,5
NEPGRE01,10,6
NEPGRE01,10,7
NEPGRE01,10,8
NEPGRE01,10,9
# 2  
Old 03-14-2012
Hi,

Could you please provide us desire output ?

~ Pravin ~
# 3  
Old 03-14-2012
Code:
NEW:	NEPGRE01,10,13			1
NEW:	NEPGRE01,10,14			1
NEW:	NEPGRE01,10,15			1
NEW:	NEPGRE01,10,16			1
NEW:	SYDGRE04,10,1			1
NEW:	SYDGRE04,10,2			1
NEW:	SYDGRE04,10,3			1
NEW:	SYDGRE04,10,4			1
NEW:	SYDGRE04,10,5			1
NEW:	SYDGRE04,10,6			1
NEW:	SYDGRE04,10,7			1
NEW:	SYDGRE04,10,8			1
	NEPGRE01,10,4			2
	NEPGRE01,10,5			2
	NEPGRE01,10,6			2
	NEPGRE01,10,7			2
	NEPGRE01,10,8			2
	NEPGRE01,10,9			2
	SYDGRE04,10,9			2
	SYDGRE04,10,10			2
	SYDGRE04,10,11			2
	SYDGRE04,10,12			2
	SYDGRE04,10,13			2
	SYDGRE04,10,14			2
	SYDGRE04,10,15			2

comparing file ciscoresets_20120314 against ciscoresets_20120313 above is desired output, it is the latest file which needs comparing.
please see post 1 to test code to see if it meets all requirements.

Last edited by slashbash; 03-14-2012 at 04:22 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Compare & print content of file which is not matching

Hi All I want to compare 2 files using awk and get output of content which is not matching I have 2 files a.txt 123 456 780 143 b.txt A|B|C|167|D|E C|K|D|123|D|E A|B|D|789|G|F C|D|G|143|A|B Not matching line from b.txt O/P A|B|C|167|D|E A|B|D|789|G|F (3 Replies)
Discussion started by: aaysa123
3 Replies

2. Shell Programming and Scripting

Compare & subtract lines in files by column using awk.

I have two files with similar column pattern as given below : 2 sample lines from file1 are given below. 18 12630 . G T 49.97 . AC=2;AF=1.00;AN=2;DP=3;Dels=0.00;FS=0.000;HRun=0;HaplotypeScore=0.0000;MQ=60.00;MQ0=0;NDA=1;QD=16.66;SB=-0.01 GT:AD:DP:GQ:PL ... (2 Replies)
Discussion started by: vaibhavvsk
2 Replies

3. Shell Programming and Scripting

Compare last 90 logs and print repeating lines with >20

*log files are in date order sample logs... ciscoresets_20120314 ciscoresets_20120313 ciscoresets_20120312 ciscoresets_20120311 ciscoresets_20120310 cat ciscoresets_20120314 SYDGRE04,10,9 SYDGRE04,10,10 SYDGRE04,10,11 SYDGRE04,10,12 SYDGRE04,10,13 SYDGRE04,10,14 SYDGRE04,10,15... (2 Replies)
Discussion started by: slashbash
2 Replies

4. Shell Programming and Scripting

Compare multiple files and print unique lines

Hi friends, I have multiple files. For now, let's say I have two of the following style cat 1.txt cat 2.txt output.txt Please note that my files are not sorted and in the output file I need another extra column that says the file from which it is coming. I have more than 100... (19 Replies)
Discussion started by: jacobs.smith
19 Replies

5. Shell Programming and Scripting

Print lines between a regExp & a blank line

Hi, I have a file, say files_list, as below (o/p of ls -R cmd) $ cat files_list /remote/dir/path/to/file: sub-dir1 sub-dir2 sub-dir3 ... /remote/dir/path/to/file/sub-dir1: remote_file1.csv.tgz <blank line 1> /remote/dir/path/to/file/sub-dir2: remote_file2.csv.tgz <blank... (3 Replies)
Discussion started by: dips_ag
3 Replies

6. Shell Programming and Scripting

Compare Tab Separated Field with AWK to all and print lines of unique fields.

Hi. I have a tab separated file that has a couple nearly identical lines. When doing: sort file | uniq > file.new It passes through the nearly identical lines because, well, they still are unique. a) I want to look only at field x for uniqueness and if the content in field x is the... (1 Reply)
Discussion started by: rocket_dog
1 Replies

7. Shell Programming and Scripting

Compare two strings, and print lines containing mismatches

pls help me on this... and im really sorry because i really don't know where to start here... FILE1 ABC DEF 10 2 DEF GHI 11 3 GHI JKL 12 5 JKL MNO 13 7 MNO PQR 14 5 requirements: 1. The third string should only be 10 or 12 2. The fourth string should only be 2 or 3 3. Prinnt... (1 Reply)
Discussion started by: kingpeejay
1 Replies

8. Shell Programming and Scripting

Compare two files and print the two lines with difference

I have two files like this: #FILE 1 ABCD 4322 26485 JMTJ 5311 97248 XMPJ 4321 58978 #FILE 2 ABCD 4321 26485 JMTJ 5311 97248 XMPJ 4321 68978 What to do: Compare the two files and find those lines that doesn't match. And have a new file like this: #FILE 3 "from file 1" ABCD 4322 26485... (11 Replies)
Discussion started by: kingpeejay
11 Replies

9. Solaris

basic hardware & system requirements for solaris 10

hi all, i want to setup a solaris10 lab for 50 trainees. kindly let me know all the basic hardware & system requirements for the lab . with regards, Raj (5 Replies)
Discussion started by: rajp_8007
5 Replies

10. Shell Programming and Scripting

awk to compare lines of two files and print output on screen

hey guys, I have two files both with two columns, I have already created an awk code to ignore certain lines (e.g lines that start with 963) as they wou ld begin with a certain string, however, the rest I have added together and calculated the average. At the moment the code also displays... (3 Replies)
Discussion started by: chlfc
3 Replies
Login or Register to Ask a Question