Home > Articles, Tools & Filters > Remove backup files ending with “~” from your system.

Remove backup files ending with “~” from your system.

Many text editors create backup files with names ending with “~”.

Most of the times these files are annoying and unnecessary…

So, you can use the following piped commands to remove them :

find / | grep "^.*~$"
       | sed -e 's/\(^.*$\)/"\1"/g'
       | xargs rm -f > /dev/null 2>&1

Please take account that this version handles correctly also filepaths containing space characters.

  1. May 7, 2013 at 16:25

    The approach of P. Christeas as I have written is only for GNU find version which probably is located in a GNU/Linux operating system.

    However, the article is more general since there is no reference to GNU operating systems (e.g. GNU/Linux, GNU/Hurd).

  2. May 7, 2013 at 12:16

    Dude… P. Christeas approach is the correct method.

    If find missing delete then its not a GNU/Linux distro.

  3. May 1, 2013 at 17:25

    There are many ways to achieve this.

    I didn’t want to use ‘-delete’ since this option might be missing from some versions of ‘find’.

    We could use also ‘-exec rm’ but both ‘-delete’ and ‘-exec’ are for GNU find.

    Other versions might not have these smart options yet.

  4. P. Christeas
    May 1, 2013 at 16:59

    find -name ‘*~’ -delete

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: