zsh (you're actually using
zsh syntax in your code; with
bash, you'd need to quote those variables):
rm -- $target/*(-@)
rm -- $target/<20150101-20151231>.log.gz(-@)
*(@) matches the files of type symlink.
*(-@) are the ones that are still of type symlink after symlink resolution (that is, those for which the target of the symlink can't be resolved). That's equivalent to GNU
zsh and with GNU
ln, you'd rather write your loop as:
ln -srt $target -- $origin/<20150101-20151231>.log.gz
Which would also work even if
$origin contains a relative path (and creates relative symlinks which reduces the risk of symlinks to be broken if some path components of the origin (the ones that are common with that of the target) are renamed in the future).