I would like to unlink the symbolic links like this:
unlink *
However it says unlink: extra operand
I would like to only delete the link file, keep original file.
I would like to unlink the symbolic links like this:
unlink *
However it says unlink: extra operand
I would like to only delete the link file, keep original file.
Using the "*" you're trying to unlink all files and directories under your current location.
unlink can't handle files or directories, it can handle only links, use the find command to find all links and unlink them, like this:
find . -type l -exec unlink {} \;
I would avoid spawning other processes with find … -exec …. When you need to unlink or rm the results of find, use its -delete option instead.
find . -maxdepth 1 -type l -delete
This command will find all the symlinks (-type l) in current directory (not in subdirectories; your * doesn't descend to subdirectories so I assume this is what you want) and delete them. The default behavior is not to follow symlinks, so the original files won't be affected.
This command will find and remove all symlinks in current folder, it will not recurse into subfolders, and it will ignore dotfiles
find . -maxdepth 1 -type l ! -name '.*' -delete