1&20070102&string3&string4....
2&20070101&string3&string4....
3&20061212&&string3&string4....
####
3&20061212&&string3&string4....
2&20070101&string3&string4....
1&20070102&string3&string4....
####
opendir(INDIR, $outdir) or die ("$indir not found\n");
while (my $infile = readdir(INDIR)) {
chomp;
next if $infile !~ /postpaid/;
#change & to space for sorting purpose
qx(cat $outdir/$infile |sed 's/\&/\t/g' > $outdir/$infile.tmp);
#sort the data based on date or second colum
qx(cat $outdir/$infile.tmp |sort -2 > $outdir/$infile.srt);
#change back the space to &
#NOTE: This one not working
qx(cat $outdir/$infile.srt |sed 's/\t/\&/g' > $outdir/$infile.ok);
#remove temporary file
qx(rm -f $outdir/$infile.tmp);
}
closedir(INDIR);