Skip to content

Command Line Reference

Mikhail Deynekin edited this page Dec 23, 2025 · 2 revisions

πŸ“– Complete Command Guide

This is the complete reference for all Clean BOM Senior command-line options, flags, and parameters.


πŸš€ Basic Syntax

./clean-bom-senior.sh [OPTIONS] [PATH]

Required Arguments

Argument Type Description Example
PATH Directory Path to scan /home/user/project

Optional Options

All options are optional and can be combined:

# Single option
./clean-bom-senior.sh --dry-run /path

# Multiple options
./clean-bom-senior.sh --dry-run --verbose --backup /path

🎯 Core Options

--dry-run

Preview changes without modifying files.

./clean-bom-senior.sh --dry-run /path/to/files

Output:

[DRY-RUN] Scanning directory...
[BOM DETECTED] file1.php (UTF-8 BOM)
[BOM DETECTED] file2.json (UTF-8 BOM)
[NO CHANGES] file3.md
Total processed: 3
To be cleaned: 2

Use cases:

  • Before running actual cleaning
  • Check what will be modified
  • Verify no unintended changes

--backup

Create backup copies with .bak extension.

./clean-bom-senior.sh --backup /path/to/files

Result:

original.php          (cleaned)
original.php.bak      (backup)

Use cases:

  • Safety net for first-time use
  • Preserve original versions
  • Easy rollback if needed

--verbose

Show detailed processing information.

./clean-bom-senior.sh --verbose /path/to/files

Output includes:

  • Every file processed
  • BOM type detected
  • Encoding changes
  • Skip reasons
  • Summary statistics

Use cases:

  • Understand what happened
  • Troubleshoot issues
  • Monitor progress

🎨 File Selection Options

--file-type TYPE

Process only specific file type.

# Process only PHP files
./clean-bom-senior.sh --file-type php /path

# Process only JSON files
./clean-bom-senior.sh --file-type json /path

# Process only text files
./clean-bom-senior.sh --file-type text /path

Supported types:

  • php - PHP code
  • python - Python code
  • javascript - JavaScript code
  • json - JSON data
  • yaml - YAML config
  • html - HTML pages
  • css - CSS styles
  • text - Plain text
  • code - All code files
  • data - All data files

Use cases:

  • Target specific file type only
  • Avoid processing unrelated files
  • Type-specific cleaning rules

--exclude DIRS

Skip specified directories.

# Skip one directory
./clean-bom-senior.sh --exclude vendor /path

# Skip multiple directories
./clean-bom-senior.sh --exclude vendor,node_modules,dist /path

Common exclusions:

--exclude vendor,node_modules,dist,.git,build

Use cases:

  • Skip third-party code (vendor, node_modules)
  • Avoid build directories
  • Exclude version control (.git)
  • Skip temporary folders (dist, build)

πŸ”§ Advanced Options

--recursive

Process directories recursively (default behavior).

./clean-bom-senior.sh --recursive /path

Note: This is the default behavior; rarely needed explicitly.


--no-recursive

Process only files in top directory.

./clean-bom-senior.sh --no-recursive /path

Use cases:

  • Process one directory only
  • Avoid nested subdirectories
  • Specific directory level targeting

--fix-crlf

Convert Windows CRLF to Unix LF.

./clean-bom-senior.sh --fix-crlf /path

# Fix both BOM and CRLF
./clean-bom-senior.sh --fix-crlf /path

Converts:

  • \r\n (CRLF - Windows) β†’ \n (LF - Unix)

Use cases:

  • Fix mixed line endings
  • Prepare for Unix servers
  • Standardize line endings

--force

Force processing without confirmation.

./clean-bom-senior.sh --force /path

Use cases:

  • Scripting/automation
  • CI/CD pipelines
  • Batch processing

--fix-gitattributes

Update .gitattributes file.

./clean-bom-senior.sh --fix-gitattributes /path

Adds:

* text eol=lf
*.php text eol=lf
*.js text eol=lf

Use cases:

  • Prevent future CRLF issues in Git
  • Standardize team line endings
  • Enforce encoding standards

πŸ“Š Reporting Options

--report FILE

Save results to file.

./clean-bom-senior.sh --report results.txt /path

Output format:

Clean BOM Senior - Processing Report
Date: 2025-01-20 14:30:00
Directory: /home/user/project

Files Processed: 47
BOM Removed: 12
CRLF Fixed: 5
Errors: 0

Detailed Results:
[CLEANED] index.php
[CLEANED] config.json
[SKIPPED] vendor/file.php (excluded)

--log LEVEL

Set logging level.

# Detailed logging
./clean-bom-senior.sh --log debug /path

# Normal logging
./clean-bom-senior.sh --log info /path

# Minimal logging
./clean-bom-senior.sh --log error /path

πŸ“‹ Common Command Combinations

Safe Test (Recommended First)

./clean-bom-senior.sh --dry-run --verbose /path

Result: See exactly what will change, no modifications.


Production Clean with Backup

./clean-bom-senior.sh --backup --verbose /path

Result: Clean files, keep backups, show progress.


Clean Specific Type Only

./clean-bom-senior.sh --file-type php /path

Result: Process only PHP files.


Full Cleanup (BOM + CRLF)

./clean-bom-senior.sh --fix-crlf /path

Result: Remove BOM and fix line endings.


CI/CD Automation

./clean-bom-senior.sh --force --exclude vendor,node_modules --dry-run /path

Result: Check without changes, suitable for CI/CD gates.


πŸ” Exit Codes

Use exit codes in scripts:

Code Meaning Action
0 Success Changes made
1 No changes Nothing to clean
2 Errors Check output
3 Path not found Verify path
4 Permission denied Check permissions

Example in script:

./clean-bom-senior.sh /path
if [ $? -eq 0 ]; then
    echo "BOM successfully cleaned!"
else
    echo "No BOM found or error occurred"
fi

πŸ’‘ Pro Tips

  1. Always dry-run first

    ./clean-bom-senior.sh --dry-run /path
  2. Backup critical files

    ./clean-bom-senior.sh --backup /path
  3. Use verbose for understanding

    ./clean-bom-senior.sh --verbose /path
  4. Exclude vendor/node_modules

    ./clean-bom-senior.sh --exclude vendor,node_modules /path
  5. Combine options

    ./clean-bom-senior.sh --dry-run --verbose --exclude vendor /path

Complete reference for all Clean BOM Senior commands and options.

Clone this wiki locally