linux - While read line is very slow -


i want create thumbs large list of images. problem is, appears while read line slow large lists. 1 solution can think of create files contain max 500 lines , read them 1 one. there smart solution problem?

while read line;   if [ -e "$line" ] && [ ! -z "$line" ];               ...   fi } done <<< "$imageslist" 

your problem you're using here string read in these lines via <<<. slow if here string large.

if $imgagelist file, can file redirect , lot faster:

while read line     if [ -e "$line" -a ! -z "$line" ]            ...     fi done < "$imageslist_file"  # redirect file. 

you might able this:

echo "$imageslist" | while read line         if [ -e "$line" -a ! -z "$line" ]            ...     fi done 

but, worried overloading command line. in linux/unix systems, defined in /usr/include/sys/syslimits.h or /usr/include/syslimits.h. it's 1024 * 256 on system or 262,144 bytes. sounds lot, can deceptive. file names can quite long -- if include directory path in them. long enough pass when you're testing, fail when really, depending upon work. and. fails silently. never know last few file names dropped off.

your best bet create file list of image names instead of loading them in environment variable.


Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -