My script runs too slow :-(...


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users My script runs too slow :-(...
# 1  
Old 06-13-2005
My script runs too slow :-(...

Hello experts,

I have a series issue in script that result with bad peformence and I wonder if you can assist me.

For example
I have two files:

File-New, size 15Mb.
File-Old, size 1Mb.

File-New content:
a
b
c
k
File-Old content:
d
f
a
b
c
Result fiel should be:
!a
!b
!c
-k

The current script takes every line in the File-New and search it in File-Old and add ! if found and - if not.

The script runs forever(1:30 hour...)
For 5000 lines processed against 14Mb file.

Any idea how to improve it?

The script that currently runs, do the following:
#!/bin/sh
#Input:
# $1 means File-Old
# $2 means File-New
#! - MarkForChange
#- MarkForDeletetion
while read line
do
grep -Fi "$line" $2 >/dev/null 2>&1
if [ "$?" -eq "0" ]; then
echo "! $line"
else
echo "- $line"
fi
done < $1


Do you have any idea how to improve the process.(It take more then hour to run...:-(

Thanks,
Roy.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Script only runs first time through crontab

Hello, I am trying to run a script through crontab and it runs the first time and then it does not run. I tried to run a simple script (as shown below) and I see the same issue. #!/bin/ksh clear echo "Good Morning, World." > /tmp/test123 Crontab Entry: 30 09 * * *... (9 Replies)
Discussion started by: hasn318
9 Replies

2. Shell Programming and Scripting

Script runs in endless loop

Hi, AM very new to shell scripting and try to run a simple do while loop statement, but it ends up running endlessly. please can anyone assist, dunno what am doing wrong, any useful suggestions will be welcomed. #!/bin/ksh ### To check a running process instance #################... (5 Replies)
Discussion started by: bayoo
5 Replies

3. Shell Programming and Scripting

Script runs but does not execute rm -rf command

Hi! First off I'm no bin/bash script writer! :( I can make heads and tales of it from the php experience I have and that's all. Now I managed to piece this script together to go look at directory and remove files that are +60 days. It's finding the files but its not removing them. I... (11 Replies)
Discussion started by: MrBiggz
11 Replies

4. UNIX for Dummies Questions & Answers

[SOLVED] Only half my script runs

Hello out there, I got this script that runs partly fine by my crontab. Problem is it gets to the sleep 300(which should be 5 minutes right?) part and never runs the rest of the scripts past that. All individual scripts run just fine. My var/mail file only shows it up to the " echo "Loader Stop... (3 Replies)
Discussion started by: vsekvsek
3 Replies

5. UNIX for Dummies Questions & Answers

Alias script which runs with cronjob

Hi, I wrote a alias script and I want to run this script every day at 10 AM. I don't want to mention this alias command in .profile(Since alias commands are nearly 30 to use). so when I'm trying to call script with cronjob its not running, any help on this. the script looks like : ... (2 Replies)
Discussion started by: rockingvj
2 Replies

6. UNIX for Dummies Questions & Answers

Script only runs as a particular user

Hi guys So I've got this PERL script that for one reason or another I need to run as a user other than the user that created the script. When I su - to another user the script won't run and doesn't give me any output as to why. No permission denied or anything like that. I've chmod 777'd the... (5 Replies)
Discussion started by: Jaymoney
5 Replies

7. Shell Programming and Scripting

How would you return how long a script runs for?

When running a ksh script, how would you time how long it took the script ran for? Is there a command that can capture this? (1 Reply)
Discussion started by: Jazmania
1 Replies

8. Shell Programming and Scripting

Shell script which runs sql script

Hi all, I need a shell script which runs a sql script but I couldn't find how to finish it. This is the code that I have: #! /usr/bin/ksh export SHELL=/bin/ksh export ORACLE_SID=database export ORACLE_HOME=/opt/oracle/product/9.2.0.8 sqlplus user <<EOF @/path/path/path/scriptname.sql... (3 Replies)
Discussion started by: Geller
3 Replies

9. Shell Programming and Scripting

Shell Script: want to insert values in database when update script runs

Hi , I am new to linux and also also to shell scripting. I have one shell script which unpacks .tgz file and install software on machine. When this script runs I want to insert id,filename,description(which will be in readme file),log(which will be in log file) and name of unpacked folder... (1 Reply)
Discussion started by: ring
1 Replies
Login or Register to Ask a Question
Path::Class::File::Stat(3pm)				User Contributed Perl Documentation			      Path::Class::File::Stat(3pm)

NAME
Path::Class::File::Stat - cache and compare stat() calls on a Path::Class::File object SYNOPSIS
use Path::Class::File::Stat; my $file = Path::Class::File::Stat->new('path','to','file'); # $file has all the magic of Path::Class::File # sometime later if ($file->changed) { # do something provocative } DESCRIPTION
Path::Class::File::Stat is a simple extension of Path::Class::File. Path::Class::File::Stat is useful in long-running programs (as under mod_perl) where you might have a file handle opened and want to check if the underlying file has changed. METHODS
Path::Class::File::Stat extends Path::Class::File objects in the following ways. use_md5 Calling this method will attempt to load Digest::MD5 and use that instead of stat() for creating file signatures. This is similar to how File::Modified works. changed Returns the previously cached File::stat object if the file's device number and inode number have changed, or if the modification time or size has changed. Returns 0 (false) otherwise. While File::Modified uses a MD5 signature of the stat() of a file to determine if the file has changed, changed() uses a simpler (and probably more naive) algorithm. If you need a more sophisticated way of determining if a file has changed, use the restat() method and compare the cached File::stat object it returns with the current File::stat object. Example of your own changed() logic: my $oldstat = $file->restat; my $newstat = $file->stat; # compare $oldstat and $newstat any way you like Or just use File::Modified instead. restat Re-cache the File::stat object in the Path::Class::File::Stat object. Returns the previously cached File::stat object. The changed() method calls this method internally if changed() is going to return true. SEE ALSO
Path::Class, Path::Class::File, File::Signature, File::Modified AUTHOR
Peter Karman, <karman@cpan.org> COPYRIGHT AND LICENSE
Copyright (C) 2006 by Peter Karman This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2012-01-28 Path::Class::File::Stat(3pm)