03-23-2009
script to add numbers is slow
Hi,
I am running a BASH shell with the following script. The script works and gives me correct output but is very slow with large files. The more rows and columns (width and height) the slower as you can probably see.
How can I do what I want more efficiently? Any ideas welcome. It has been ages since I have gone down the scripting road and - wow - it is slow to come back.
Thanks in advance.
i=$(($WIDTH * $HEIGHT - $WIDTH - 1))
k=$(($WIDTH - 1))
for ((j=0;j<$i;j++))
do
if [[ $j -eq $k ]]
then echo $((k=$(($k + $WIDTH))))
else
second=$(( j + 1 ))
third=$(( j + WIDTH + 1))
fourth=$(( j + WIDTH))
echo "4 $j $second $third $fourth" >> file.out
fi
done
10 More Discussions You Might Find Interesting
1. UNIX for Advanced & Expert Users
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 (0 Replies)
Discussion started by: roybe
0 Replies
2. Shell Programming and Scripting
cat dailyreports | grep "Important list" | awk -F":" '{print $2}' | awk -F" " '{print $1}'
hey guys, after running the above combination of cat and awk, i get the below output:
3
4
2
9
now, i need to add these numbers up all in one line. i dont know what to add to that cat and awk one... (2 Replies)
Discussion started by: Terrible
2 Replies
3. Shell Programming and Scripting
I have a bash script that will take approx. 130 days to complete. I am trying to grep a list of 1,144 user ID's out of 41 (1 GB each) files. The 41 files were originally one 41 G file, but that was horrendously too slow.:eek:
This is my current file:
#!/bin/bash
for i in `cat... (11 Replies)
Discussion started by: tigta09
11 Replies
4. Shell Programming and Scripting
I had written a perl script to compare two files: new and master and get the output of the first file i.e. the first file: words that are not in the master file
STRUCTURE OF THE TWO FILES
The first file is a series of names
ramesh
sushil
jonga
sudesh
lugdi
whereas the second file (could be... (4 Replies)
Discussion started by: gimley
4 Replies
5. UNIX for Dummies Questions & Answers
My script builds a lot of these array lists, then compares their sizes which solves my problem, but runs very slow. :(
set -A comboSorted -- $(
for x in ${IDs}
do
nawk -v s=$x '
BEGIN { testPattern="^" s "$" }
{
if ( $2 ~ testPattern ) {
getline;getline;
if ($1 == "IMAGE_SIZE")
print... (1 Reply)
Discussion started by: nerdcurious
1 Replies
6. Shell Programming and Scripting
Basically my requirement is to know the total number of free anonymous ports.
anonymous port range is 32768- 65535.
i wrote a script for that
**********************************************
for i in {32768..65535}
do
netstat -an | grep $i > /dev/null
if
... (21 Replies)
Discussion started by: mohtashims
21 Replies
7. Shell Programming and Scripting
Hi
I know the basic about script and sleep processes.
However this is more tricky:
I would like to run
sh -x /sbin/dhclient-script and slow down the output of the script as a whole.
How would you do it?
I would like to delay output on the screen with 1 second for every line for the output... (3 Replies)
Discussion started by: medium_linux
3 Replies
8. Shell Programming and Scripting
Hello all,
Currently I am using a script with "curl" to get the an alert if 200 ok would not be grepped.and the link is down.
is it possible to get an alert mail if a particular link on a website is not completely down but SLOW?? (0 Replies)
Discussion started by: chirag991
0 Replies
9. Shell Programming and Scripting
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
10. Shell Programming and Scripting
Gents,
Please can u help me to improve this script to be more faster, it works perfectly but for big files take a lot time to end the job..
I see the problem is in the step (while) and in this part the script takes a lot time..
Please if you can find a best way to do will be great.
... (13 Replies)
Discussion started by: jiam912
13 Replies
LEARN ABOUT DEBIAN
xpstops
XPSTOPS(1) XPS Tools XPSTOPS(1)
NAME
xpstops - XPS to PostScript converter
SYNOPSIS
xpstops [OPTION...] FILE [OUTPUT FILE]
DESCRIPTION
xpstops converts XPS documents to PostScript format. xpstops reads the XPS file, FILE, and writes a PostScript file, OUTPUT FILE. If
OUTPUT FILE is not specified the output filename will be derived from the OUTPUT FILE filename.
OPTIONS
-?, --help
Show help options.
-d DOCUMENT, --document=DOCUMENT
The document inside the XPS file to convert. By default, the first document of the XPS file is used.
-f PAGE, --first=PAGE
The first page to convert.
-l PAGE, --last=PAGE
The last page to convert.
-o, --odd
Convert only odd pages.
-e, --even
Convert only even pages.
-r RESOLUTION, --resolution=RESOLUTION
Horizontal and vertical resolution in PPI (Pixels Per Inch). The default is 150 PPI.
--rx=RESOLUTION
Horizontal resolution in PPI (Pixels Per Inch). The default is 150 PPI.
--ry=RESOLUTION
Vertical resolution in PPI (Pixels Per Inch). The default is 150 PPI.
-x X, --crop-x=X
The x-coordinate of the crop area top left corner.
-y Y, --crop-y=Y
The y-coordinate of the crop area top left corner.
-w WIDTH, --crop-width=WIDTH
The width of crop area.
-h HEIGHT, --crop-height=HEIGHT
The height of crop area.
--level2
Generate Level 2 PostScript. Level 2 supports color images and image compression.
--level3
Generate Level 3 PostScript. This enables all Level 2 features plus shading patterns and masked images. This is the default setting.
--eps
Generate an Encapsulated PostScript (EPS) file.
--paper=PAPER
Set the paper size to one of "A0", "A1", "A2", "A3", "A4", "A5", "B4", "B5", "Letter", "Tabloid", "Ledger", "Legal", "Statement",
"Executive", "Folio", "Quarto", "10x14".
--duplex
Adds the %%IncludeFeature: *Duplex DuplexNoTumble DSC comment to the PostScript file. This tells the print manager to enable duplexing.
--paper-width=WIDTH
The paper width.
--paper-height=HEIGHT
The paper height.
--expand
Expand pages smaller than the paper to fill the paper. By default, pages are not scaled.
--no-shrink
Don't scale pages which are larger than the paper. By default, pages larger than the paper are shrunk to fit.
--no-center
Don't center on the paper pages smaller than the paper (after any scaling). By default, pages smaller than the paper are aligned to the
lower-left corner.
BUGS
Please send bug reports to https://bugzilla.gnome.org/enter_bug.cgi?product=libgxps.
SEE ALSO
xpstojpeg(1) xpstopng(1) xpstopdf(1) xpstosvg(1)
XPS Tools 11/19/2011 XPSTOPS(1)