Skip to content

Instantly share code, notes, and snippets.

@vbsteven
Created July 19, 2019 09:11
Show Gist options
  • Save vbsteven/6fc93960111d4ab8a566d46b915f381f to your computer and use it in GitHub Desktop.
Save vbsteven/6fc93960111d4ab8a566d46b915f381f to your computer and use it in GitHub Desktop.
Prepend one file to another in bash
# this will find all folders with a file named versions.tf
# and prepend its contents to the file main.tf in the same directory
for p in $(find -name "versions.tf"); do
main=$(echo $p | sed 's/versions/main/' );
echo -e "$(cat $p)\n\n$(cat $main)" > $main;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment