-1

I need to remove a large number of symbolic links from a folder that has other files which I don't want to remove. Is there any easy way to remove only symbolic links?

ZakS
  • 1,073
  • 3
  • 15
  • 27
  • Stack Overflow is a site for programming and development questions. You should use another site on the [Stack Exchange network](https://stackexchange.com/sites) for this question. – jww Dec 30 '18 at 18:51

1 Answers1

1

You can use the find(1) command

 find . -maxdepth 1 -type l -exec rm {} \;
  • -maxdepth 1 is for only scanning current directory.
  • -type l is for searching symbolic links
  • -exec executes rm to delete given file, the {} being replaced by find with an appropriate path, and the \; ending the sub-command run by find

See also the man page of rm(1) (and of ls(1), mv(1), cp(1), ln(1), stat(1) if you want to use them in a variant of that find command).

Basile Starynkevitch
  • 223,805
  • 18
  • 296
  • 547
Derviş Kayımbaşıoğlu
  • 28,492
  • 4
  • 50
  • 72