UNIX command to dereference a symbolic link?
You can use readlink
to find out the filename, but you don't have to!
cp b c
mv c b
It's that simple. If you are writing a script to do that, you should use
the output of mktemp
instead of c
to make sure you don't override already existing file
c
.
Combining both answers leads to the following:
#!/bin/bash
if [ -h "$1" ] ; then
target=`readlink $1`
rm "$1"
cp "$target" "$1"
fi