Skip to content

Instantly share code, notes, and snippets.

@fabiolimace
Last active May 6, 2024 14:46
Show Gist options
  • Save fabiolimace/7d1e2e592257e916fe101fe3dddc1e84 to your computer and use it in GitHub Desktop.
Save fabiolimace/7d1e2e592257e916fe101fe3dddc1e84 to your computer and use it in GitHub Desktop.
Install scripts in `/usr/local/bin`
#!/usr/bin/bash
#
# Install script files located in /usr/local/bin/scripts into /usr/local/bin
#
# First, put the scripts you want to install inside /usr/local/bin/scripts; then run this script.
#
# The script will look for files with these extensions: awk, py, sh.
#
bin=/usr/local/bin;
scripts=$bin/scripts;
regex=".*\.\(awk\|py\|sh\)";
function symbolic-link {
local file=${1}
local type=${1##*.}
echo ln -s $file $bin/`basename $file .$type`;
sudo ln -s $file $bin/`basename $file .$type`;
}
for i in `find $scripts -type f -regex "$regex"`;
do
echo chmod +x $i;
sudo chmod +x $i;
symbolic-link $i;
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment