All pastes #895365 Raw Edit

Stuff

public shellscript v1 · immutable
·published 2008-02-07 19:34 UTC
rendered paste body
#!/bin/bashprefix="sg_"suffix=".csv"linesInFile=`wc -l $1 | cut -d' ' -f1`index=0dirId=0maxFiles=5000;linesPerFile=200000;old=0new=0while [ $new -le $linesInFile ]do        dirName="${prefix}${dirId}"        if [ $index -eq 0 ] ; then                if [ -e "/home/gmateev/Desktop/test/${dirName}" ] ; then                        dirId=$((dirId+1))                        echo "Directory already exists, incrementing"                        continue                else                        mkdir $dirName                fi        fi        old=new        new=$((new+linesPerFile))        name="${prefix}${index}${suffix}"        head --lines=${new} $1 | tail --lines=$linesPerFile > /home/gmateev/Desktop/test/${dirName}/${name};        index=$((index+1))        if [ $index -gt $maxFiles ] ; then                dirId=$((dirId+1))                index=0        fidone