03-31-2009
need inputs on how i can change my script to reduce amount of time the script takes
HI ,
I have a list1 which consists of data that i have to search and a list2 which has the files that need to be searched .So basically i am using list1 on list2 to see if list1 data is present if found replace it .I have written the code using foreach loop for each list .This is taking the script longer time because the data and the number of files to be search is more....Is there a way i can reduce the time the scripting is takes? I saw somehwere we can use pipe to collect data and doa parallel serach ...but not sure on how to use it
here is teh present code that i have
@list_of_newhier1------------list1
@list_of_newhier-------------list2
foreach $other_list(@list_of_newhier1)
{
chomp(@list_of_newhier1);
if(not ($other_list=~/^\$/) and $other_list=~/\s*(.*).$prefix\.([^\.\t ]+)$/)
{
$other_list=~/\s*(.*).$prefix\.([^\.\t ]+)$\s*/;
$other_list1 = $1;
$other_list2=$2;
foreach $list_of_newhier(@list_of_newhier)
{
chomp(@list_of_newhier);
open(NEWHIER, "$dirname1/$other_list")or die " Can not open $other_list $! \n";
open(NEWHIER1, ">$dirname1/$other_list.tmp")or die " Can not open $other_list.tmp \n";
while(<NEWHIER>)
{
if(/$list_of_newhier/)
{
$_=~s/\b$list_of_newhier\b/$list_of_newhier.$prefix/ ;
}
print NEWHIER1 $_;
}
close(NEWHIER);
close(NEWHIER1);
$sys_err = system("cp $dirname1/$other_list.tmp $dirname1/$other_list");
$sys_err = system(" rm $dirname1/$other_list.tmp");
}
}
}
Thanks
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I am writing a script that takes two parameters: the name of another script and an integer that represents a number of seconds. The script must execute the second script (first parameter) for the specified number of seconds (second parameter), suspend it for the same number of seconds, and continue... (9 Replies)
Discussion started by: ponchorage
9 Replies
2. Shell Programming and Scripting
Hi all,
I wrote this shell script to validate filed numbers for input file. But it take forever to complete validation on a file. The average speed is like 9mins/MB.
Can anyone tell me how to improve the performance of a shell script?
Thanks (12 Replies)
Discussion started by: ozzman
12 Replies
3. UNIX for Dummies Questions & Answers
Hello Everybody,
Please help.
I was trying to automate the use of a third-party given shell script. The script is written to be used at run-time to collect a few variables to be provided by the user through key board, in the fashion as below:
./runcommand
please provide a file name to... (6 Replies)
Discussion started by: Dingrong
6 Replies
4. Shell Programming and Scripting
Ok, I sort of need to create a command files that will be ftped to another server to run.
I have some input variable that will need to be read, and then transformed into another script file. Here are some examples.
Server 1:
outputCmd.sh
passing in ./outputCmd.sh nh8oaxt Release_4_0... (1 Reply)
Discussion started by: orozcom
1 Replies
5. Shell Programming and Scripting
Hi. I wanted to create a Perl script which can take the outputs of a Perl script as it's input and temporarily store them in a document. Need help.
Thanks.:) (8 Replies)
Discussion started by: xtatic
8 Replies
6. Shell Programming and Scripting
DELETED. (0 Replies)
Discussion started by: vasuvv
0 Replies
7. Shell Programming and Scripting
Hi,
I am using solari 10 OS which is having bash shell.
I need a shell script which takes user home directory and name of the file or directory as a input and based on that copy the files accordingly to the other directory.
example:I hava a machine1 which is having some files in a... (8 Replies)
Discussion started by: muraliinfy04
8 Replies
8. Shell Programming and Scripting
Hi,
I am using solaris 10 bash shell.this might a small script but i am not much familiar with scripting.
My requirement here is script should prompt for users two opions like this
"please select either any one option makefile or make& build file".
if the user selects make file option... (2 Replies)
Discussion started by: muraliinfy04
2 Replies
9. Shell Programming and Scripting
Hi everybody!
I need to perform a task with a script but I have no idea how to do it, I hope someone could help me:
- on my linux pc I have many folders with movies, tv shows, toons, ecc.
They are shared by a dlna server to my panasonic tv where I can browse and see them.
The problem is that... (6 Replies)
Discussion started by: Torquemada
6 Replies
10. Shell Programming and Scripting
AFILENAME=glow.sh
FILENAME="/${AFILENAME}"
WIDTHA=$(echo ${FILENAME} | wc -c)
NTIME=0
RESULTS=$(for eachletter in $(echo ${FILENAME} | fold -w 1)
do
WIDTHTIMES=$(awk "BEGIN{printf... (5 Replies)
Discussion started by: SkySmart
5 Replies
LEARN ABOUT DEBIAN
ns_foreach
ns_lctl(3aolserver) AOLserver Built-In Commands ns_lctl(3aolserver)
__________________________________________________________________________________________________________________________________________________
NAME
ns_for, ns_foreach, ns_while, ns_lctl - Replacements for standard Tcl loop commands which enable monitoring and control
SYNOPSIS
ns_for start test next body
ns_foreach varname list body
ns_foreach varlist1 list1 ?varlist2 list2 ...? body
ns_while test body
ns_lctl cancel id
ns_lctl eval id script
ns_lctl info id
ns_lctl install command
ns_lctl list
ns_lctl pause id
ns_lctl result id
_________________________________________________________________
DESCRIPTION
The ns_for, ns_foreach, and ns_while commands are replacements for cooresponding Tcl commands with the additional capability of monitoring
and control through the ns_lctl command.
ns_for start test next body
See the for(n) man page for usage.
ns_foreach start test next body
See the foreach(n) man page for usage.
ns_foreach varlist1 list1 ?varlist2 list2 ...? body
See the foreach(n) man page for usage.
ns_while test body
See the while(n) man page for usage.
ns_lctl cancel id
Mark the given loop to cancel at the next iteration, resulting in the loop returning with TCL_ERROR.
ns_lctl eval id script
ns_lctl info id
ns_lctl install command
ns_lctl list
ns_lctl pause id
ns_lctl result id
SEE ALSO
for(n), foreach(n), while(n)
KEYWORDS
threads, iteration, list, looping, cancel
AOLserver 4.5 ns_lctl(3aolserver)