[KLUG Programming] sorting, uniq'ing, and grepping
Adam Williams
programming@kalamazoolinux.org
14 Jul 2003 12:17:33 -0400
> > I've got a process that I am trying to convert to a C program. In short, I
> > need to combine two files into one, sort the resulting file, grab the unique
> > lines, then pull out certain bits. I currently accomplish it this way (psuedo
> > code):
> > cat file1 > newfile
> > cat file2 >> newfile
> > sort newfile > sortfile
> > uniq -uw7 sortfile > uniqfile
> > grep criteria1 uniqfile > importfile
> > grep criteria2 uniqfile > removefile
> > I then take the importfile and removefile and process them into LDIF, batch,
> > and CSV files. I think I handle that part line by line once I sort, uniq, and
> > grep.
> My solution would be done in perl. Perl is absolutely wonderful at
> kerchunking input files which are formatted like csv and outputting them
> any way you want (and I mean ANY way). I use perl to create ldif's in a
> cron job every night. At first glance of this I thought just use a bash
> script. You can accomplish the bash commands with the system(command);
> function. I am unaware if Perl can be run from the other OS's though so
> Perl may not be the best solution.
I've installed Perl on WinY2k once. Installing and configuring IIS was
more like fun.