bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bad performance for substring replacement by pattern


From: Linda Walsh
Subject: Re: Bad performance for substring replacement by pattern
Date: Sun, 18 Jul 2010 11:57:50 -0700
User-agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24 Mnenhy/0.7.6.666



Yi Yan wrote:
Hi,

     I used the following Bash script to test substring replacement operator.
It is performance get worse very quickly with the increasing of the string
length.

    I test the script with Bash(4.1) on Debian Linux machine.

    See the execution time difference by increasing the $NUM in the script:


========================================
#! /usr/local/bin/bash

declare z="start"
declare NUM=1000

#----------------------------------
# create a long string with ';'
#----------------------------------
for ((i=0; i<$NUM; i++)); do
    z="$z;string$i"
done


#------------------------------
# delete everything except ';'
#------------------------------
date +%s

x="${z//[^;]}"
echo $x

date +%s


_________________________________________________________________
The New Busy is not the too busy. Combine all your e-mail accounts with Hotmail.
----
        So you did the above and what did you find out?

        (Or did I miss an email?)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]