Skip to content

Instantly share code, notes, and snippets.

@MikaelElkiaer
Created May 27, 2020 11:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MikaelElkiaer/b93d555bb3e7f0cc204166337eea72f3 to your computer and use it in GitHub Desktop.
Save MikaelElkiaer/b93d555bb3e7f0cc204166337eea72f3 to your computer and use it in GitHub Desktop.
Rename file(s) based on resource name and kind
#!/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