Trim right columns from text file

less than 1 minute read

Related: remove left columns from text file


Old Fortran or COBOL programs may have columns 73-80 filled with vestigal card sequence numbers. Remove them or any other text more than N columns long by:

Trim right columns

This example keeps the first 72 columns of text from “ancient.for” on each row, resaving as “ancient.f”.

cut -c-72 > ancient.f < ancient.for 

Any trailing whitespace (up to 72 characters for this example) remains.

Leave a Comment