Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!purdue!ames!amdahl!pacbell!sactoh0!spked!tdl!raulin From: raulin@tdl.UUCP (Raulin Olivera) Newsgroups: comp.unix.questions Subject: Re: line length Summary: 132 char lines to 80 char lines Keywords: line length Message-ID: <127@tdl.UUCP> Date: 9 May 89 15:10:15 GMT References: <160@ohsu-hcx.UUCP> Distribution: usa Organization: CA State Controllers Lines: 63 In article <160@ohsu-hcx.UUCP>, mkb@ohsu-hcx.UUCP (Marilyn Bushway) writes: > If I have output of 132 characters and I want it to be 80 characters > is there a unix command to change the line length??? > nosun!ohsu-hcx!mkb > or > tektronix!ohsu-hcx!mkb > or nosun!ohsu-hcx!mkb@rutgers.edu > Thanks in advance > Marilyn > > -- > Marilyn Bushway 3181 S.W. Sam Jackson Park Rd. Portland, OR 97201 > (503) 279-8328 e-mail {nosun,tektronix,ogccse,qiclab} ohsu-hcx!mkb I would probalbly handle it with and AWK script depending on the size of the file. The AWK script could be run within your shell script. An example might be: : Shell commands ... awk ' { printf("%s\n%s\n", substr($0,1,80), substr($0,81,)) }' inputfile If you need speed I would do it in C. An example might be #define MAXLEN 133 main(argc, argv) int argc; char *argv[]; { int i, len; char line[MAXLEN]; FILE *fp; fp = fopen(argv[1],"r"); /* should add diagnostics here */ while(fgets(line, LENGTH, fp) != NULL) { len = strlen(line); for(i = 0; i < len; i++) { putchar(line[i]); if(i == 79) /* Carriage return after 80th char */ putchar('\n'); } putchar('\n'); } } This code should put the first 80 chars on one line and the rest of the chars on the line following. This is pretty basic and there are probably more efficient ways to do it but it should work. I didn't test this code but I think it's complete. =Ralo->