Sponsored Content
Top Forums Shell Programming and Scripting Slow Running Script (Reading 8000 lines) Post 302832009 by u20sr on Friday 12th of July 2013 12:19:04 PM
Old 07-12-2013
Slow Running Script (Reading 8000 lines)

Slow runnin script. The problem seems to be the sed calls.
In summary the script reads list of users in file1. For each
username search two files (file 1 & file2) for the username
and get the value in the next line after "=". Compare these
values with each other.

If the same then output to a file and if not output to another file.
For approx 8000 lines in file1 it takes approx 15 minutes to run?
not very good. Any suggestions on removing the bottleneck?

Script:
Code:
#!/bin/ksh
compareusernames() {
p_name="$1"
result_one=`sed -n "/$p_name/{n;p;}" $file2 | cut -d= -f2 | tr -d ' '`
result_two=`sed -n "/$p_name/{n;p;}" $file3 | cut -d= -f2 | tr -d ' '`
if [[ "$result_one" = "$result_two" ]] then
        echo "$p_name" >> matches.out
else
        echo "$p_name" >> no_matches.out
fi
 
i=0
while read v_name
do
compareusernames "$v_name"
((i=$i+1))
done < $file1


}

File1:
Code:
user1
user2
user3
user4

File2:
Code:
name=user1
gud=100
name=user2
gud=200
name=user3
gud=300

File3:
Code:
name=user1
gud=100
name=user2
gud=xxx
name=user3
gud=xxx

 

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
GEARMAN_JOB_STATUS(3)							 1						     GEARMAN_JOB_STATUS(3)

GearmanClient::jobStatus - Get the status of a background job

       Object oriented style (method):

SYNOPSIS
public array GearmanClient::jobStatus (string $job_handle) DESCRIPTION
Gets the status for a background job given a job handle. The status information will specify whether the job is known, whether the job is currently running, and the percentage completion. PARAMETERS
o $job_handle - The job handle assigned by the Gearman server RETURN VALUES
An array containing status information for the job corresponding to the supplied job handle. The first array element is a boolean indicat- ing whether the job is even known, the second is a boolean indicating whether the job is still running, and the third and fourth elements correspond to the numerator and denominator of the fractional completion percentage, respectively. EXAMPLES
Example #1 Monitor the status of a long running background job <?php /* create our object */ $gmclient= new GearmanClient(); /* add the default server */ $gmclient->addServer(); /* run reverse client */ $job_handle = $gmclient->doBackground("reverse", "this is a test"); if ($gmclient->returnCode() != GEARMAN_SUCCESS) { echo "bad return code "; exit; } $done = false; do { sleep(3); $stat = $gmclient->jobStatus($job_handle); if (!$stat[0]) // the job is known so it is not done $done = true; echo "Running: " . ($stat[1] ? "true" : "false") . ", numerator: " . $stat[2] . ", denomintor: " . $stat[3] . " "; } while(!$done); echo "done! "; ?> The above example will output something similar to: Running: true, numerator: 3, denomintor: 14 Running: true, numerator: 6, denomintor: 14 Running: true, numerator: 9, denomintor: 14 Running: true, numerator: 12, denomintor: 14 Running: false, numerator: 0, denomintor: 0 done! SEE ALSO
GearmanClient::doStatus. PHP Documentation Group GEARMAN_JOB_STATUS(3)
All times are GMT -4. The time now is 07:20 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy