Skip to content

Instantly share code, notes, and snippets.

@simonrenger
Created August 25, 2019 12:38
Show Gist options
  • Save simonrenger/5a945e3aef06619ed9282f302077c93d to your computer and use it in GitHub Desktop.
Save simonrenger/5a945e3aef06619ed9282f302077c93d to your computer and use it in GitHub Desktop.
#!/bin/bash
echo "License Append script"
license=$1
ending=$2
folder=*
file=""
scan_for_folders(){
for i in $folder; do
if [ -d $i ]
then
folder=$i/*
scan_for_folders
else
file=$i
edit_file
fi
done
}
edit_file(){
local content=""
if [ -f $file ]
then
if [[ $file == $ending ]]
then
cat $license $file > $file".new"
mv $file".new" $file
fi
fi
}
scan_for_folders
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment