I've got a large file (2-4 gigs), made up of 4 columns. I'd like to split the file into two, based on the 2nd column value being even or odd. The following script does the job, but runs incredibly slow--I'm not sure it will complete this week.
There must be a clever way to do this with just awk.
#!/bin/bash
while read line
do
tmp=`echo $line| awk '{print $2}'`
tmp=$(( $tmp % 2))
if [ $tmp -eq 0 ]
then
echo $line >> even.dat
else
echo $line >> odd.dat
fi
done < input.dat