Removing Files By Extension Type

Discussion in 'Linux Guides' started by Chuck, Mar 16, 2018.

  1. Chuck

    Chuck Administrator
    Staff Member Grep What?

    Joined:
    May 17, 2017
    Messages:
    39
    Likes Received:
    0
    If you need to remove all files with a certain extension type you can use the following:

    Code:
    find . -name "*.bak" -type f -delete
    This will remove all files with extension type ".bak". It will not remove a directory. If you want to see exactly which files will be deleted before actually running the command you can do:

    Code:
    find . -name "*.bak" -type f
    Note: Do not change the format of these commands unless you know what you are doing. If you were lets say to move "-delete" forward a few spots you would delete everything in the directory.

    For more information on using find:
    Code:
    man find
     

Share This Page