Sponsored Content
Top Forums Shell Programming and Scripting Slow Running Script (Reading 8000 lines) Post 302836169 by Don Cragun on Tuesday 23rd of July 2013 04:16:39 PM
Old 07-23-2013
Quote:
Originally Posted by u20sr
don_cragun : Good point. These should be sent to a file - something like no_results.out

Also, if there is a null returned after the = in file2 then this should be sent to no_gud.out
Your requirements are still ambiguous. The following awk script puts a name found in File1 into one of four files:
  1. in no_results.out if the name does not appear in File2 and does not appear in File3,
  2. in no_gud.out if the name appears in File2 or File3 but not in both, or if the gud=value line in either file has an empty value string,
  3. in no_matches.out if the name appears in File2 and File3 and the value in gud=value in both files is not empty but the values are different, or
  4. in matches.out if the name appears in both files, neither value is empty, and both values are identical.
If this isn't what you want, please restate your exact requirements.
Code:
awk -F= '
FILENAME != lf {
        f++
        lf = FILENAME
}
$1 == "name" {
        u = $2
        next
}
$1 == "gud" {
        f == 1 ? r1[u] = $2 : r2[u] = $2
}
f == 3 {if(!($1 in r1) && !($1 in r2)) print > "no_results.out"
        else    if(!($1 in r1) || r1[$1] == "" ||
                   !($1 in r2) || r2[$1] == "") print > "no_gud.out"
        else    if(r1[$1] != r2[$1]) print > "no_matches.out"
        else    print > "matches.out"
}' File2 File3 File1

As always, if you try running this on a Solaris/SunOS system, use /usr/xpg4/bin/awk, /usr/xpg6/bin/awk, or nawk instead of /bin/awk or /usr/bin/awk.
This User Gave Thanks to Don Cragun For This Post:
 

10 More Discussions You Might Find Interesting

1. Solaris

Solaris running very slow!!

Hi all, Solaris is working very slow as login to solaris takes time say after 10 to 15 mins we get the login prompt back after logging in as oracle account/other account. This causes most Batch run delays(DWHouse jobs) scheduled through cronjobs. Where should one look for such issues to... (3 Replies)
Discussion started by: a1_win
3 Replies

2. SCO

Server running slow

Hi, Wonder is someone can help. I've got a server SCO_SV 3.2v5.0.7 PentIII that is located at a different site and is running slow and has been for a week. I've been speaking to a third party who say nothing is wrong with it but its still running slow. The 3rd party advise it could be a... (2 Replies)
Discussion started by: tez
2 Replies

3. HP-UX

SAM running slow

Any ideas on why SAM would take so long to load and initialize? (4 Replies)
Discussion started by: csaunders
4 Replies

4. UNIX for Dummies Questions & Answers

Unix is running slow??

All, This is my interview questions. Let me explain the question. Some one is asking me that, the unix server is running very slow. As a unix unix admin, what are the steps we should follow?? What/which process we should check?? What is the way to find the root cause ? Please let me know.... (8 Replies)
Discussion started by: govindts
8 Replies

5. Shell Programming and Scripting

Reading multi lines variable using shell script

Hi, I am using #!/bin/sh shell. I have a variable which contains multi line data. I want to read that variable line by line. Can someone post the code to read the multi line variable line by line? Any help is much appreciated. (2 Replies)
Discussion started by: gupt_ash
2 Replies

6. Shell Programming and Scripting

script for reading logs of a script running on other UNIX server

Hi, I have a script, running on some outside firwall server and it's log of success or failure is maintained in a file. I want to write a script which ftp that server and reads that file and checks the logs and if failure , I will send mail notification. Please let meknow if I am not... (1 Reply)
Discussion started by: vandana.parwani
1 Replies

7. Shell Programming and Scripting

awk script - reading input lines

Can I do something like, if($0==/^int.*$/) { print "Declaration" } for an input like: int a=5; If the syntax is right, it is not working for me, but I am not sure about the syntax. Please help. Thanks, Prasanna (1 Reply)
Discussion started by: prasanna1157
1 Replies

8. UNIX for Dummies Questions & Answers

Ubuntu seems running slow!

Hello, My PC seems running slow: OS32 system, Pentium(R)4---2.40Ghz, 1GB RAM, 80GB HDI am running Ubuntu 11.10 (Oneiric Ocelot) alone in this box, which seems very slow to me. Is this normal? Compared with my other PC (Running XP) with 1.99GHz AMD Athlon 3200+, 2GB RAM,500GB HD, XP and Mint... (11 Replies)
Discussion started by: yifangt
11 Replies

9. AIX

AIX server running very slow

Hello, All the commands on AIX are running very slow. Below is few stats but I didn't find any issue in cpu or memory reosurces vmstat System configuration: lcpu=4 mem=6144MB ent=1.00 kthr memory page faults cpu ----- -----------... (2 Replies)
Discussion started by: Vishal_dba
2 Replies

10. Shell Programming and Scripting

Shell script reading file slow

I have shell program as below #!/bin/sh echo ======= LogManageri start ========== #This directory is getting the raw data from remote server Raw_data=/opt/ftplogs # This directory is ready for process the data Processing_dir=/opt/processing_dir # This directory is prcoessed files and... (4 Replies)
Discussion started by: Chenchireddy
4 Replies
All times are GMT -4. The time now is 12:39 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy