Sponsored Content
Top Forums Shell Programming and Scripting awk, associative array, compare files Post 302565835 by shruthi123 on Wednesday 19th of October 2011 01:23:45 AM
Old 10-19-2011
Network thank you

Its really working awesome.But my question is my original file1.txt and file2.txt have records in millions,so does it take huge time or efficient enough.

---------- Post updated at 11:21 PM ---------- Previous update was at 11:12 PM ----------

i need to compare the same for filed3 also.Iam java developer so no idea about shell script please help me regarding this also.I mean to say if filed3 filed2 changes i need to show both changes.
File1.txt
'393200103088';'TIM';'20060207'
File2.txt
'393200103088';'TIM';'20060208'
common.txt(Filed3 has changed for filed1)
'393200103088' '20060201' '2006208'

---------- Post updated at 11:39 PM ---------- Previous update was at 11:21 PM ----------

I had generated file3.txt by the following command.
diff file1.txt file2.txt > file3.txt
If you look into file3.txt
The records missing from file2 started with < symbol.
And the records missing from file1 started with > symbol.
And it also has coommon records(coomon first field)using this i have to generate same three files as i have mentioned in previous thread.
1.misssed_file1.txt
2.missed_file2.txt
3.common.txt
< '393200103052';'H3G';'20081204'
< '393200103059';'TIM';'20110111'
< '393200103061';'TIM';'20060206'
< '393200103064';'OPI';'20110623'
> '393200103052';'HKG';'20081204'
> '393200103056';'TIM';'20110111'
> '393200103088';'TIM';'20060206'
I think here > and < symobls are helpful to generate required files.
please help me regarding this.

---------- Post updated 10-19-11 at 12:23 AM ---------- Previous update was 10-18-11 at 11:39 PM ----------

my orginial file sizes
file1.txt-604 mb
file2.txt-422 mb
i had tested your code with original files its taking much time to process the files.please help me how i can optimize time.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Associative Array

Hi, I am trying to make an associative array to use in a popup_menu on a website. Here is what i have: foreach $entr ( @entries ) { $temp_uid = $entr->get_value(uid); $temp_naam = $entr->get_value(sn); $s++; } This is the popup_menu i want to use it in. popup_menu(-name=>'modcon',... (4 Replies)
Discussion started by: tine
4 Replies

2. Shell Programming and Scripting

Problem with lookup values on AWK associative array

I'm at wits end with this issue and my troubleshooting leads me to believe it is a problem with the file formatting of the array referenced by my script: awk -F, '{if (NR==FNR) {a=$4","$3","$2}\ else {print a "," $0}}' WBTSassignments1.txt RNCalarms.tmp On the WBTSassignments1.txt file... (2 Replies)
Discussion started by: JasonHamm
2 Replies

3. Shell Programming and Scripting

Help needed on Associative array in awk

Hi All, I got stuck up with shell script where i use awk. The scenario which i am working on is as below. I have a file text.txt with contents COL1 COL2 COL3 COL4 1 A 500 400 1 B 500 400 1 A 500 200 2 A 290 300 2 B 290 280 3 C 100 100 I could able to sum col 3 and col4 based on... (3 Replies)
Discussion started by: imsularif
3 Replies

4. Shell Programming and Scripting

Associative array

I have an associative array named table declare -A table table="fruit" table="veggie" table="GT" table="eminem" Now say I have a variable returning the value highway How do I find corresponding value GT ?? (this value that I find (GT in this case) is supposed to be the name of a mysql... (1 Reply)
Discussion started by: leghorn
1 Replies

5. Shell Programming and Scripting

Bash 3d associative array with bash3 AND multiple files

Hello again guru’s (big apologies for wall of text) Still working on that DNS updater for my production team and while there is a ton of hit in searches i can't seem to find the answer to this. Context: We have apps that switch from let’s say host1 to host2. REAL basic DNS clustering... (5 Replies)
Discussion started by: maverick72
5 Replies

6. Shell Programming and Scripting

Morse Code with Associative Array

Continuing my quest to learn BASH, Bourne, Awk, Grep, etc. on my own through the use of a few books. I've come to an exercise that has me absolutely stumped. The specifics: 1. Using ONLY BASH scripting commands (not sed, awk, etc.), write a script to convert a string on the command line to... (22 Replies)
Discussion started by: ksmarine1980
22 Replies

7. Shell Programming and Scripting

Awk: Dealing with whitespace in associative array indicies

Is there a reliable way to deal with whitespace in array indicies? I am trying to annotate fails in a database using a table of known fails. In a begin block I have code like this: # Read in Known Fail List getline < "'"$failListFile"'"; getline < "'"$failListFile"'"; getline <... (6 Replies)
Discussion started by: Michael Stora
6 Replies

8. Shell Programming and Scripting

Using associative array for comparison

Hello together, i make something wrong... I want an array that contains information to associate it for further processing. Here is something from my bash... You will know, what I'm trying to do. I have to point out in advance, that the variable $SYSOS is changing and not as static as in my... (2 Replies)
Discussion started by: Decstasy
2 Replies

9. Shell Programming and Scripting

Associative array index question

I am trying to assign indexes to an associative array in a for loop but I have to use an eval command to make it work, this doesn't seem correct I don't have to do this with regular arrays For example, the following assignment fails without the eval command: #! /bin/bash read -d "\0" -a... (19 Replies)
Discussion started by: Riker1204
19 Replies

10. UNIX for Beginners Questions & Answers

awk Associative Array and/or Referring to Field by String (Nonconstant String Value)

I will start with an example of what I'm trying to do and then describe how I am approaching the issue. File PS028,005 Lexeme HRS # M # PhraseType 1(1:1) 7(7) PhraseLab 501 503 ClauseType ZYq0 PS028,005 Lexeme W # L> # BNH # M #... (17 Replies)
Discussion started by: jvoot
17 Replies
SC_TRACEDIFF(1) 					    BSD General Commands Manual 					   SC_TRACEDIFF(1)

NAME
sc_tracediff -- display traceroute paths where the path has changed. SYNOPSIS
sc_tracediff [-a] [-m method] [-n] file1.warts file2.warts DESCRIPTION
The sc_tracediff utility displays pairs of traceroutes to a destination where the path has changed. It takes two warts files as input and displays paths where a hop differs by its address. The options are as follows: -a dump all traceroute pairs regardless of whether they have changed. -m method specifies the method used to match pairs of traceroutes together. If dst is specified, traceroutes are matched if the destination IP address of both traces are the same. If userid is specified, traceroutes are matched if the userid field of both traces are the same. If dstuserid is specified, traceroutes are matched if the destination IP address and userid fields are the same. By default, the destination IP address is used. -n names should be reported instead of IP addresses, where possible. sc_tracediff can be useful in network monitoring to identify when a forward IP path has changed. In this scenario, it is recommended that Paris traceroute is used with the same UDP source and destination ports for each execution of scamper so that only paths that have changed are identified, not merely alternate paths visible due to per-flow load-balancing. By default scamper uses a source port based on the process ID, which will change with each execution of scamper. EXAMPLES
The command: scamper -O warts -o file1.warts -c 'trace -P udp-paris -s 31337' -f list.txt collects the forward IP paths towards a set of IP addresses found in list.txt using 31337 as the UDP source port value. If the above command is adjusted to subsequently collect file2.warts, then we can identify paths that have subsequently changed with the command: sc_tracediff file1.warts file2.warts If Paris traceroute with ICMP probes is preferred, then the following invocation of scamper is appropriate: scamper -O warts -o file1.warts -c 'trace -P icmp-paris -d 31337' -f list.txt In this case, scamper uses 31337 as the ICMP checksum value in each probe. SEE ALSO
scamper(1), B. Augustin, X. Cuvellier, B. Orgogozo, F. Viger, T. Friedman, M. Latapy, C. Magnien, and R. Teixeira, Avoiding traceroute anomalies with Paris traceroute, Proc. ACM/SIGCOMM Internet Measurement Conference 2006. AUTHOR
sc_tracediff is written by Matthew Luckie <mjl@luckie.org.nz>. BSD
April 21, 2011 BSD
All times are GMT -4. The time now is 12:34 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy