Created
May 27, 2020 11:26
-
-
Save MikaelElkiaer/b93d555bb3e7f0cc204166337eea72f3 to your computer and use it in GitHub Desktop.
Rename file(s) based on resource name and kind
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/sh | |
get_filename() { | |
cat $1 | yq -r '(.metadata.name|ascii_downcase) + "_" + (.kind|ascii_downcase) + ".yaml"' | head -n 1| xargs echo | |
} | |
for x in $(exa -G $1); do mv -T $x $(get_filename $x); done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment