1.1 KiB
Executable file
1.1 KiB
Executable file
add_yaml_header
This script automates the process of ensuring that YAML files within a specified directory contain the necessary --- header. If a YAML file does not have the --- header, the script adds it.
Usage
Run the script with the directory containing your YAML files as an argument. The script will check each file in the directory (and its subdirectories) to see if it starts with ---. If the header is missing, the script will add it.
./add_yaml_header <directory>
Example Usage
Automatically add --- headers to YAML files in the specified directory:
./add_yaml_header /path/to/directory
Script Details
- The script uses
fdto find all files with the.yamlor.ymlextension in the specified directory. - For each file, it checks if the first line is
---. - If the
---header is missing, it adds it to the top of the file usingsed.
Notes
- Ensure
fdis installed (brew install fdon macOS). - The script modifies files in place; consider using version control to track changes.