[Bash] Find and Remove Files in One Line of Command


Use find command to find all files with specific name and delete them in one line of command.

Quesion

Find all files with the name WS_FTP.LOG in content/extra directory, and remove them at the same time.

Answer

$ find content/extra/ -name "WS_FTP.LOG" | xargs rm

Tested on: Ubuntu Linux 16.04, find (GNU findutils) 4.7.0-git


References:

[1]

unix pipe delete file - Google search

unix - Command line: piping find results to rm - Stack Overflow