A shell script that tidies up plain text files by:
- Converting to UNIX line endings (LF)
- Ensuring a POSIX-compliant EOF (trailing newline)
- Removing trailing whitespace from each line
- Removing trailing empty lines at the end of the file
./tidyup.sh file1.txt file2.txt ...Pass one or more file paths as arguments. Each file is modified in place.
The following tools must be available on your system:
| Tool | Purpose |
|---|---|
dos2unix |
Converts Windows (CRLF) line endings to UNIX (LF) |
sed (GNU) |
Ensures POSIX EOF; strips trailing whitespace and empty lines |
On macOS, GNU sed is required and is expected as gsed.
On Linux, the standard sed and dos2unix packages are sufficient.
| Platform | Status |
|---|---|
| macOS | Supported (requires gsed) |
| Linux | Supported |
| Windows (MinGW/Cygwin) | Supported |