Sponsored Content
Top Forums Shell Programming and Scripting Compare field and get the missing in Linux shell. Post 302732081 by sabercats on Friday 16th of November 2012 02:08:19 PM
Old 11-16-2012
Compare field and get the missing in Linux shell.

I have a log file A.txt
Code:
2012/11/13 20:06:11 |t112|Locations 12, 13, 14, 15|NET12/full_ddr3_2X_FV_4BD_1.qt|norway|0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15|norway22
2012/11/14 14:23:19 |t112|Locations 0, 1, 2, 3, 4, 5, 6, 7|NET24/full_111_ddr5_soq523_2X_FV.qt|norway|0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15|norway10
2012/11/14 14:23:19 |a108|Locations 0, 1|NET24/full_111_ddr5_soq523_2X_FV.qt|germany|0,1,2,3|germany10
2012/11/14 16:23:19 |a108|Locations 0, 1,2,3|NET24/full_111_ddr5_soq523_2X_FV.qt|holland|0,1,2,3|holland10

How we do i get the result out put
Code:
2012/11/13 20:06:11 |t112|Locations 12, 13, 14, 15|NET12/full_ddr3_2X_FV_4BD_1.qt|norway|0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15|norway22
2012/11/14 14:23:19 |t112|Locations 0, 1, 2, 3, 4, 5, 6, 7|NET24/full_111_ddr5_soq523_2X_FV.qt|norway|0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15|norway10
Currenttime|Available|Locations 8,9,10,11|Available|norway|0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15|norway18 
** norway18 is 10+8 from locations 8 is available, this line not in out put **
2012/11/14 14:23:19 |a108|Locations 0, 1|NET24/full_111_ddr5_soq523_2X_FV.qt|germany|0,1,2,3|germany10
Currenttime|Available|Locations 2,3|Available|germany|0,1,2,3|germany12 
** germany12 is 10+2 from locations 2 is available,  this line not in out put **
2012/11/14 16:23:19 |a108|Locations 0, 1,2,3|NET24/full_111_ddr5_soq523_2X_FV.qt|holland|0,1,2,3|holland10

*** holand have locations 0,1,2,3 matched so it do nothing.
How you use compare field 3 Location with field #6 to find missing location in ksh script? Thanks.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

deleting records with a missing field

I had to delete rows when a record was missing a field. My solution was cut -c 202-402 ${dataFile} | awk '{if (substr($0,103,30) !~ /^ *$/) print $0} >> ${workFile} The cut is because they came two records to a row. Anyone want to offer a more elegant solution? (2 Replies)
Discussion started by: gillbates
2 Replies

2. Shell Programming and Scripting

Compare files in two folders and delete missing ones

I do not know much about shell scripting so I am at a loss here. If someone can help me, that would be great! I have two directories /dir1 /dir2 I need to delete all files from /dir1 and that does not have a correspondent file in /dir2. It should NOT check file suffixes in /dir2 . Why?... (20 Replies)
Discussion started by: kaah
20 Replies

3. 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

4. Shell Programming and Scripting

Insert missing field using perl,sed,awk

sample file (comma as field separators) MessageFlow,1,BusIntBatchMgr,a OOBEvent,1,BusIntBatchMgr,a TaskEvents,1,,a MTTrace,1,,a MTWarning,,1,a MessageFlow,1,Batch,a OOBEvent,1,Batch,a TaskEvents,1,,a EAISAPIdocWizard,1,BusIntMgr,a EAISAPBAPIWizard,1,BusIntMgr,a... (3 Replies)
Discussion started by: vrclm
3 Replies

5. Shell Programming and Scripting

Compare Field in Current Line with Field in Previous

Hi Guys I have the following file Essentially, I am trying to find the right awk/sed syntax in order to produce the following 3 distinct files from the file above: Basically, I want to print the lines of the file as long as the second field of the current line is equal to the... (9 Replies)
Discussion started by: moutaye
9 Replies

6. Shell Programming and Scripting

Compare two files Field by field and output the result in another file

Hi Friends, Need Help. I have file1.txt as File1.txt |123|A|7267|Hyder|Cross|Sell|7801 |995|A|7051|2008|Lunar|New|Year|Promotion|7801 |996|A|7022|Q108|Targ|Prospect|&|SSCC|Savings|Promo|7801 |997|A|7182|Q1|Feb-Apr|08|Credit|ITA|PA|SBA|Campaign|7801 File2.txt... (7 Replies)
Discussion started by: i150371485
7 Replies

7. Shell Programming and Scripting

Plz Help. Compare 2 files field by field and get the output in another file.

Hi Freinds, I have 2 files . one is source.txt and second one is target.txt. I want to keep source.txt as baseline and compare target.txt. please find the data in 2 files and Expected output. Source.txt 1|HYD|NAG|TRA|34.5|1234 2|CHE|ESW|DES|36.5|134 3|BAN|MEH|TRA|33.5|234... (5 Replies)
Discussion started by: i150371485
5 Replies

8. Shell Programming and Scripting

Linux Script to compare two folders and copy missing files

Hi, I need help in shell scripting. If someone can help me, that would be great! Problem. I want Linux Script to compare two folders and copy missing files. Description. I have two directories /dir1 /dir2 I need to copy all distinct/new/unique/missing files from /dir1 and that... (1 Reply)
Discussion started by: S.Praveen Kumar
1 Replies

9. Shell Programming and Scripting

Compare two files and get only missing names

I need to compare two files (oldfile1 & newfile). Need to ignore the values which are present in both files. At the same time, i need to get only records in new file. Tried using Join -v1 -v2 oldfile1 newfile (suspect it has not worked as expected). could anyone of you please help me here. (5 Replies)
Discussion started by: Selva_2507
5 Replies

10. UNIX for Beginners Questions & Answers

Linux/Shell script - How to compare 2 arrays based on patterns and get the differences

I have FILE 1 (This file has all master columns/headers) A|B|C|D|E|F|G|H|STATUS FILE 2 A|C|F|I|OFF_STATUS 3|4|5|4|Y 6|7|8|5|Y Below command give me all headers of FILE 2 into array2.txt file paste <(head -1 FILE2.txt | tr '|' '\n')>array2.txt So I would like to compare... (2 Replies)
Discussion started by: jmadhams
2 Replies
Graphics::Primitive::Insets(3pm)			User Contributed Perl Documentation			  Graphics::Primitive::Insets(3pm)

NAME
Graphics::Primitive::Insets - Space between things DESCRIPTION
Graphics::Primitive::Insets represents the amount of space that surrounds something. This object can be used to represent either padding or margins (in the CSS sense, one being inside the bounding box, the other being outside) SYNOPSIS
use Graphics::Primitive::Insets; my $insets = Graphics::Primitive::Insets->new({ top => 5, bottom => 5, left => 5, right => 5 }); METHODS
Constructor new Creates a new Graphics::Primitive::Insets. Instance Methods as_array Return these insets as an array in the form of top, right, bottom and left. bottom Set/Get the inset from the bottom. equal_to Determine if these Insets are equal to another. left Set/Get the inset from the left. right Set/Get the inset from the right. top Set/Get the inset from the top. zero Sets all the insets (top, left, bottom, right) to 0. AUTHOR
Cory Watson, "<gphat@cpan.org>" SEE ALSO
perl(1) COPYRIGHT &; LICENSE Copyright 2008-2010 by Cory G Watson. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.12.3 2010-08-21 Graphics::Primitive::Insets(3pm)
All times are GMT -4. The time now is 03:21 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy