cktb -- Check for trailing blanks (spaces, tabs) in a file
cktb.pl is a Perl program which checks for trailing blanks (space or tabs) in a text file and reports the number found and the longest string of blanks found. This was written because one place I worked didn't want any spaces or tabs at the end of each line in programs. So this program checks for it. It's easier to get a report where this issue is found than trying do it in your editor (although some editors can get rid of spaces at the end of the lines, like vim). And if anyone thinks they've gotten rid of them you can show them a report from this program.
- Show cktb.pl code
- Download: cktb.pl
Limitations:
- This is written in Perl so needs Perl available.
- It is a command line program and would generally run on Linux or Unix.
- The program only reports the locations of trailing blanks. It is left to the user to remove them, if desired.
Usage
cktb.pl [-l] filename [filename...] where: -l gives long output, instead of a summary.For example, here is a file with some trailing white space and what the report will show.
Input (9 lines): A line with no trailing blanks.| A line with one trailing blank. | A line with several trailing blanks | A line with a lot of trailing blanks | Output (default): ~> cktb.pl cktbtest.in cktb.pl: Find lines with trailing spaces or tabs, by Kent Nassen, v1.1, 6/11/99 Report generated: Sun Aug 10 09:16:50 2025 9 total lines in the file 'cktbtest.in'. Longest string of trailing whitespace was 22 characters at line 8. Output (using -l option): cktb.pl -l cktbtest.in Page 1 cktb.pl: Find lines with trailing spaces or tabs, by Kent Nassen, v1.1, 6/11/99 Scanning for trailing white space in the file: cktbtest.in Report generated: Sun Aug 10 09:18:09 2025 Trailing WS Line# Length ------- ----------- 4 1 6 3 8 22 9 total lines in the file 'cktbtest.in'. Longest string of trailing whitespace was 22 characters at line 8.
Back to Kent's Perl Page Last-modified: Sun Aug 10 10:19:26 EDT 2025