How do I delete the target of a symbolic link without deleting the link itself?
using find
to find the symlink and then using readlink
to get the full path to the target to rm
:
find ~/Desktop/ -type l -name 'test.txt' -exec bash -c 'rm "$(readlink -f "$1")"' _ {} \;
Or as you know the link name already:
rm "$(readlink -f ~/Desktop/test.txt)"
Simply use:
printf "" > "$(readlink '/path/to/link')"
to clear the file, or
rm "$(readlink '/path/to/link')"
to remove the file.