Skip to content

Append spaces to justify comments in tree view.

The tree command can be used to create a folder structure overview. It is nice to add nicely alligned comments that explain folder elements.

Create a tree directory overview showing 4 levels.

tree -L 4 > tmp.txt
Append spaces to tmp.txt until line length 45 is metachieved, and output this to tmp2.txt:
awk -v l="45" '{s="%-"l"s\n";printf(s,$0);}' tmp.txt > tmp2.txt

The result after adding some comments:

$ cat tmp2.txt
.
├── composer.json                           # Specifies the Drupal installation.
├── composer.lock
├── crontab                                 # Crontab that runs in Drupal tools container.
├── drupal
│   ├── config
│   │   └── sync                            # Storage location for Drupal configuration.
│   ├── private_files                       # Storage location for Drupal private files.
│   ├── profiles
│   │   └── drups                           # Custom Drups Drupal profile that will be installed.
│   └── settings
│       ├── settings.append                 # Drupal settings that will be appended to default settings.php.
│       ├── settings.cluster.php            # Drupal settings only active in remote deployment.
│       └── settings.lando.php              # Drupal settings only active in local deployment.
└── web                                     # Drupal root directory.
    └── sites
        └── default
            ├── files
            ├── settings.cluster.php        # Drupal settings only loaded in remote deployment.
            ├── settings.lando.php          # Drupal settings only loaded in local deployment.
            ├── settings.local.php          # Default local settings loaded in local deployment.
            └── settings.php                # Drupal settings loaded both in local and remote deployment.

Back to top