DEGAS — Remove excess spaces and blank lines from text.

Syntax:
DEGAS /A:attribs /B:n /CP:n /E:n /H /L /N /P /R /S /T /W filename…

/A:attribsattributes mask; valid flags are -ACEHIORS
/B:nmaximum whitespace characters
/CP:ninterpret non-Unicode input text using code page n
/E:nmaximum blank lines
/Hdisplay filenames
/Ldisplay line numbers
/Ndisable features
/Ppage output
/Rremove all blank lines at the start and end of the file
/RSremove all blank lines at the start of the file
/REremove all blank lines at the end of the file
/Ssearch in subdirectories for matching files
/Ttrim all leading and trailing whitespace from each line
/Wconvert all whitespace characters to ASCII spaces
Range options are also supported.

The contents of the files will be dumped to standard output, with excess spaces and blank lines removed.

Input filenames may be specified on the command line, or text may be redirected or piped into DEGAS. If you want to pipe to DEGAS, remember that pipes open a new shell. To pipe to a plugin command, you must either ensure that the plugin is loaded in the transient shell, e.g. by installing the .DLL file in the shell’s PlugIns directory; or else use temporary files or an in-process pipe.

You may specify more than one filename; wildcards and directory aliases are supported. You can search recursively into subdirectories for matching files with /S. @File lists and internet files are supported. You may also specify CLIP: to dump the clipboard.


/B: lets you specify the maximum number of whitespace characters in a row. For example, /B:4 allows no more than four whitespace characters in a row.

DEGAS allows for the convention of spacing twice at the end of a sentence. Specify two numbers separated by a comma: /B:n,m. The first sets the maximum number of whitespace characters after a period, question mark, or exclamation point; the second is the maximum after any other character. /B:2,1 allows up to two spaces at the end of a sentence, but only one elsewhere.


/E: specifies the maximum number of blank lines in a row. (A line containing only whitespace characters is considered a ‘blank line’.) /E:3 allows no more than three blank lines together. /E:0 removes all blank lines; /E:0 can be abbreviated to /E.


You can remove all blank lines at the start of a file with /RS. Likewise, you can remove all blank lines at the end of a file with /RE. /R does both. This option is independent of the /E: compression of blank lines.


/T strips all leading and trailing whitespace from each line. This is a separate operation from the /B: compression of spaces, and happens earlier.


If none of /B: /E: /R /RS /RE or /W are specified, the default is /B:2,1 /E:1 — a maximum of two spaces at the end of a sentence, one space elsewhere; and no more than one blank line in a row.


/N disables features:

/NBdo not write a Byte Order Mark
/NCdisable highlight
/NDdo not search into hidden directories; only useful with /S
/NFsuppress the file-not-found error
/NJdo not search into junctions; only useful with /S
/NZdo not search into system directories; only useful with /S

You can combine these, e.g. /NDJ.