#!/bin/bash
# Check if a prefix is supplied
if [ -z "$1" ]; then
"Usage: $0 <prefix>"
echo 1
exit
fi
# Define the source directory and the prefix
=~/og_files
SOURCE_DIR=$1
PREFIX
# Loop through files with the specified prefix and create symlinks
for file in "$SOURCE_DIR"/"$PREFIX"*; do
if [[ $(basename "$file") != "$PREFIX"d* ]]; then
-s "$file" .
ln "Created symlink for $(basename "$file")"
echo
fi done
1. Create Bash Script
Put all the bash code
below into a new bash script (e.g. do_symlinks.sh
)
2. Copy or Move /usr/local/bin
and Source .bashrc
/usr/local/bin/do_symlinks && . ~/.bashrc sudo cp do_symlinks.sh
3. Create and change directory into test1
folder
&& cd test1 mkdir test1
4. Run do_symlinks tony_
do_symlinks tony_
5. Confirm results ll
ll
6. Terminal Code
/usr/local/bin/do_symlinks && . ~/.bashrc
sudo cp do_symlinks.sh && cd test1
mkdir test1
do_symlinks tony_ ll