Use read as a prompt inside a while loop driven by read

function mod_uber_src {
    [ -z "$1" ] && error.w fatal "no container name was passed";
    #use node_modules folder as the last time reference
    path=./containers/$1/volumes/werm/uber_src/lib/npm/node_modules
    time_last=`stat -c '%Y' $path`;
    path=./containers/$1/volumes/werm/uber_src;
    list=`find $path -type f -printf '%T@ %p\n' | sort -k1,1nr | head -50`
    num_lines=`echo "$list" | wc -l`;
    i=0;
   while [ $num_lines -gt $i ]
    do
        i=$(($i+1))
        line=`sed -n ${i}p <<< "$list"`
        path=`echo $line | cut -d' ' -f2`
        time_file=`stat -c '%Y' $path`
        [ $time_file -gt $time_last ] && copy_file_from_uber_src "$path";
    done
}

Leave a Reply

Your email address will not be published.