Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

linux remove files in a directory except symlinks? [closed]

Tags:

linux

bash

In linux, how can I remove all the files in a directory except the files that are actually symlinks to files in other directories?

like image 379
719016 Avatar asked Oct 25 '25 10:10

719016


1 Answers

Using find command:

find /path/to/dir -type f -delete

-type f will ensure you only delete files not symlinks

like image 112
jaypal singh Avatar answered Oct 26 '25 22:10

jaypal singh