Re: Getting a text file rid of all superfluous blank lines

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thursday, Dec 1st 2005 at 23:30 -0000, quoth Paul Smith:

=>So many ways of solving my problem show that this list is quite creative!
=>Paul

And why is it pray tell that no one thought to use *THE* most efficient of 
all systems for this horribly CPU intensive task? I refer you all to flex 
of course. As long as you're using deterministic regular expressions then 
this is the best there is.

Here's foo.l

/* Note that the square brackets contain space tab */

%%%%%%%%%%%%%%%%%%START OF foo.l%%%%%%%%%%%%%%%%%%%
%%
[\n	]	putchar('\n');
[\n	]{2,}	puts ("\n\n");
.*		printf ( "%s", yytext );
%%
#include <stdio.h>
%%%%%%%%%%%%%%%%%%END OF foo.l%%%%%%%%%%%%%%%%%%%

flex foo.l
gcc -O -o foo lex.yy.c -ll
./foo < input_file

-- 
Time flies like the wind. Fruit flies like a banana. Stranger things have  .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux