Tag Info

New answers tagged


Delete the folder "test" and all the files inside: rm -r test Delete all the files inside but keep the folder "test": rm -r test/*


It can be done by GNU ls+awk one-liner: ls -vr *.depot | awk -F- '$1 == name{system ("rm \""$0"\"")}{name=$1}' Explanation: the file names are passed as input to the awk script. The options -vr cause the file names to be sorted as version numbers in reverse order, so e.g. foo-1.9.depot comes after foo-1.10.depot. The awk script stores the first part of ...


$ cat remover #!/usr/bin/perl for(<*depot>){ if(/(\w.*?)-(\d+)(?:\.(\d+))?\.(\d+)-/){ $norm=sprintf("%04d%04d%04d",$2,$3,$4); if($v{$1} and $v{$1} > $norm){ system "rm '$_'\n"; next } if($v{$1} ){ system "rm '$name{$1}'\n";} $v{$1}=$norm; $name{$1}=$_; } } try perl remover and replace print by system ...


Trash-cli is a linux application that can be installed using apt-get in Ubuntu or yum in Fedora. Using the command trash listOfFiles will move the specified into your trash bin.


I would use perl, it is faster and more efficient for this than find + rm 0,30 * * * * cd /var/www/magento/var/session && /usr/bin/perl -e 'for(<sess_*>){((stat)[9]<(unlink))}' Deleting my log directory with over 500,000 logs in it daily clears it out in under ~6 minutes.


If the only thing in that directory is sess_* files, you can just leave out the -name 'sess_*', and find will traverse through anyway. Test what it would match by removing the -exec part. $ /usr/bin/find /var/www/magento/var/session -type f -mtime +1 Then for the cron job, 0,30 * * * * /usr/bin/find /var/www/magento/var/session -type f -mtime +1 -exec rm ...


Don't bother exec'ing rm at all, find can handle it: 0,30 * * * * /usr/bin/find /var/www/magento/var/session -name 'sess_*' -type f -mtime +1 -delete


Use find for that: find . ! -name '.*' ! -type d -exec rm -- {} +


try something like: find <path> ! -name '.*' -type f -exec rm {} \;

Top 50 recent answers are included