Clean $HOME directory

dot-fileshome

During a few years, in my $HOME directory a lot of hidden files
and directories appeared.

I would like to continually delete the unneeded ones.

How can I find out which applications created those hidden files
and directories.

How can I be sure that it's safe to remove the hidden files and directories
and nothing important will be lost and nothing depending on them won't
stop working?

Best Answer

You can just temporarily displace them.

cd ~
mkdir .trash
find . ! -name . -prune ! -type d -atime +365 -exec \
    sh -c 'touch -a -- "$@"
           mv -- "$@" ~/.trash
    ' --   {} +

That will find all files in your $HOME directory - without recursing into child directories - which have not been accessed for a year. It will update the access time for all of them to right now, and then move all of them into a directory named .trash. If you encounter any problems between the time you run it and whatever time you decide to start deleting old files in ~/.trash then you can try moving some of them back and see if any of those you put in the trash were the cause.

Related Question