SWPRC NOT STATED 000001 1344
SWPRC NOT STATED 000001 1362
SWPRC NOT STATED 000001 1418
SWPRC NOT STATED 000001 1436
SWPRC NOT STATED 000001 1437
SWPRC NOT STATED 000001 1438
SWPRC NOT STATED 000001 1493
If it is in sed or awk? Can you give me an example where i can implement this logic. Please note that i don;t want to read line by line of this file and do the formatting.
If you don't want to read the file line by line, how else can you read it? Or do you mean you don't want to write a shell script which reads each line one by one? sed and awk both operate specifically on one line at a time by default. Other than that, awk sounds like the tool of choice here.
Is the input file fixed-length, or is there some particular separator? Assuming this is fixed length, columns 1-5, 6-11, 12-22, and the rest, something like:
if i use cut -c 1-6 for example it will fetch the whole column of 1-6 characters and say another column 7-12.
The output of these two columns should be in the format
printf ("%s %-50s").
This way we need not read the whole file line by line.
Meanwhile i am trying to work out the logic that you have suggested.
If the lines were much longer than an input block (512 bytes on some ancient machines; something around 2 to 8 kbytes on contemporary U*ces I'd guess) then taking care to not read the file line by line might make sense, but if the sample data is representative, reading the file line by line is probably the most efficient you can get. Anyway, the awk script above should hopefully work, perhaps with some minor modifications.