I’ve created a simple Bash script that should create symlinks in /usr/local/{etc,lib,include…} from an inputted directory path
#!/bin/sh
input="$1"
for subdir in "etc include bin lib man share sbin"; do
dir=$input/$subdir
if [ -e $dir ] && [ -d $dir ]; then
for file in $dir/*; do
ln -s $file /usr/local/$subdir
done
fi
done
The error i’m getting is:
user@comp:/usr/local# ./update-locallinks /usr/local/test/
[: 6: /usr/local/test/etc: unexpected operator
and this is what /usr/local/test/ looks like:
user@comp:/usr/local# ls /usr/local/test/
bin
etc
include
lib
Always protect your bash variables with double quotes in test expressions: