[Gllug] stipping odd { } from a file

t.clarke tim at seacon.co.uk
Tue Jan 24 08:45:07 UTC 2006


Sorry
Cant thread this reply
dont shoot me !!

Ref earlier post concerning removing characters from a file of numbers with
scattered { }

Cheap and cheerful mini C prog below.
who knows,  might even be quicker than a sed script !
only used sed once in anger   -  too lazy to learn all these fancy tools
when I will only use once in a blue moon !!

Tim

ps: Apologies to all you genuine sysadmins out there  !!

and apologies for the crap C coding too  - it seems to work anyway


=======
#include <stdio.h>
/* input from stdin output to stdout*/
main(argc, argv)
int argc;
char *argv[];
{
int a=100;
char b;
/*read from stdin until eof*/
 while ( (b=getchar()) !=EOF)
 {
 if (b != '}' && b != '{' && b != '\n')
  {
  putchar(b);
  if ( a-- < 0 &&  b == ',')
   {
   putchar('\n');
   a=100;
   }
  }
 }
}





sample input:
123,123,123,123,3,4,5,6,7,8,19090{090909,1234,
123,123,123,123,3,4,5,6,7,8,190909090909,1234,
123,123,123,123,3,4,5,6,7,8,190909090909,1234,
112,123,123,123,3,4,5,6,7,8,190909}90909,1234,
123,123,123,123,3,4,5,6,7,8,190909090909,1234,
123,123,123,123,3,4,5,6,7,8,190909090909,1234,
123,123,123,123,3,4,5,6,7,8,190909090909,1234,
112,123,123,123,3,4,5,6,7,8,19090{090909,1234,
123,123,123,123,3,4,{5,6,7,8,190909090909,1234,
123,123,123,123,3,4,5,6,7,8,190909090909,1234,
123,123,123,123,3,4,5,6,7,8,1909{}090909,1234,
112,123,123,123,3,4,5,6,7,8,190909090909,1234,
123,123,123,123,3,4,5,6,7,8,190909090909,1234,
123,123,123,123,3,4,5,6,7,8,190909090909,1234,
123,123,123,123,3,4,5,6,7,8,190{09}90909,1234,
112,123,123,123,3,4,5,6,7,8,190909090909,1234,

sample output:    (line length of 50 used instead of 100):_
123,123,123,123,3,4,5,6,7,8,19090090909,1234,123,123,
123,123,3,4,5,6,7,8,190909090909,1234,123,123,123,123,
3,4,5,6,7,8,190909090909,1234,112,123,123,123,3,4,5,
6,7,8,19090990909,1234,123,123,123,123,3,4,5,6,7,8,190909090909,
1234,123,123,123,123,3,4,5,6,7,8,190909090909,1234,123,
123,123,123,3,4,5,6,7,8,190909090909,1234,112,123,123,
123,3,4,5,6,7,8,19090090909,1234,123,123,123,123,3,4,
5,6,7,8,190909090909,1234,123,123,123,123,3,4,5,6,7,
8,190909090909,1234,123,123,123,123,3,4,5,6,7,8,1909090909,
1234,112,123,123,123,3,4,5,6,7,8,190909090909,1234,123,
123,123,123,3,4,5,6,7,8,190909090909,1234,123,123,123,
123,3,4,5,6,7,8,190909090909,1234,123,123,123,123,3,
4,5,6,7,8,1900990909,1234,112,123,123,123,3,4,5,6,7,
8,190909090909,1234,

--------------------------------------------------------------------------------
This E-Mail (and any files transmitted with it) is intended solely for the use
of the individual or entity to whom it is addressed. If you have received it in
error please notify the sender and delete the message.

-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list