Shell script: Criar TAR de cada subdiretório, desreferenciando symlinks

tar_each_directory.sh
for i in ../mydir/*; do
    if [ -L "$i" ]; then
        # Dereference the symlink
        tar cvhf "$(basename "$i").tar" "$i"
    else
        # Regular tar without dereferencing
        tar cvf "$(basename "$i").tar" "$i"
    fi
done

Check out similar posts by category: Linux