Re: upper/lower case

"Daniel Goldman [email protected] [sed-users]" <[email protected]>
Newsgroups gmane.editors.sed.user
Message-ID <[email protected]>
Thanks for doing the speed test. Of course, another disadvantage of the 
while-loop script is that it hard codes (a b c d). To my understanding, 
the cut-paste script can be totally parameter-driven.

Just double-checking: The post shows IFS=',' used for while-loop script. 
Was intended IFS=';' used in actual speed test?

Daniel

On 12/12/2015 12:57 AM, Thierry Blanc [sed-users] wrote:
> speed test
>
> My concerns about a shell while loop were correct. The while-do loop is
> much slower.
>
> 1.079455912 vs. .221387482
>
>
>
> while-loop script:
>
>      #!/bin/sh
>
>      START=$(date +%s.%N)
>      while IFS=',' read a b c d
>      do
>      c="$(echo "$c" | sed -r 's/(.*)/\L\1/; s/\<(.)/\u\1/g' )"
>      echo  "$a ; $b ;$c ; $d"
>
>      done <  $1 > $2
>
>      END=$(date +%s.%N)
>      echo "$END - $START" | bc
>
>      #endofscript
>
> cut-paste script:
>
>      #!/bin/sh
>
>      START=$(date +%s.%N)
>
>      col_to_sed=3
>
>      prev_col=`expr $col_to_sed - 1`
>      next_col=`expr $col_to_sed + 1`
>
>      cut -d \;  -f -$prev_col     < $1 > cols_before.txt
>      cut -d \;  -f  $col_to_sed < $1 > cols_.txt
>      cut -d \;  -f  $next_col-    < $1 > cols_after.txt
>
>      sed -e '1b;s/.*/\L&/;s/\<./\u&/g' < cols_.txt > cols_new.txt
>
>      paste -d\;  cols_before.txt cols_new.txt cols_after.txt > output.csv
>
>      END=$(date +%s.%N)
>      echo "$END - $START" | bc
>
> #endofscript
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.