How to delete multiple files at once in Bash on Linux?

前端 未结 7 741
有刺的猬
有刺的猬 2021-01-29 19:09

I have this list of files on a Linux server:

abc.log.2012-03-14
abc.log.2012-03-27
abc.log.2012-03-28
abc.log.2012-03-29
abc.log.2012-03-30
abc.log.2012-04-02
ab         


        
7条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-29 19:45

    Use a wildcard (*) to match multiple files.

    For example, the command below will delete all files with names beginning with abc.log.2012-03-.

    rm -f abc.log.2012-03-*
    

    I'd recommend running ls abc.log.2012-03-* to list the files so that you can see what you are going to delete before running the rm command.

    For more details see the Bash man page on filename expansion.

提交回复
热议问题