Delete a list of files with find and grep

后端 未结 9 1668
一个人的身影
一个人的身影 2021-01-30 08:44

I want to delete all files which have names containing a specific word, e.g. \"car\". So far, I came up with this:

find|grep car

How do I pass

9条回答
  •  闹比i
    闹比i (楼主)
    2021-01-30 08:54

    I like to use

    rm -rf $(find . | grep car)

    It does exactly what you ask, logically running rm -rf on the what grep car returns from the output of find . which is a list of every file and folder recursively.

提交回复
热议问题