#!/bin/sh while IFS= read -r f; do link=${1:?}/${f##*/} if [ -e "$f" ] && [ ! -e "$link" ]; then ln -s "/$f" "$link" elif [ ! -e "$f" ] && [ -L "$link" ]; then rm -f "$link" fi done