You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1.2 KiB
1.2 KiB
recursivefilecmd
Execute a command on files with a specific extension recursively in a directory tree.
1. Overview
1.1. Usage
./recursivefilecmd.sh <extension> <path> <command ..>
1.1.1. Arguments
extension
: The file extension to search for.path
: The root directory to start searching for files.command
: The command to execute on each file.
1.1.2. Examples
./recursivefilecmd.sh 'hcl' 'services/' nomad run -detach
./recursivefilecmd.sh 'yaml' 'config/' kubectl apply -f
1.2. Behaviour
The file-name including its path are added to the end of the given command.
All files are executed in-sequence.
When path
is a file which matches the extension, only it is executed.
When the extension doesnt match, the directory is used instead, walking up up to 3 times, searching for files matching the extension.
2. Development
2.1. Features
Maybe i'll add some more features, here a few i can think of:
- Convert project to golang
- Add options for optional things
- Replace
extension
-filter with a regex-match - Make recursive optional
- Parameterize passed-filepath (e.g. # for all & #1 for regex-group 1)