Script – Avoid argument too long error

Posted by admin on Jun 18, 2009 in Scripts |

When removing 10,000’s of files with rm -f * you get an argument too long error.

#### Remove too man files. 
#### First find -name ‘*’ > filelist

#!/bin/bash
for i in $( cat filelist );
do
echo $i
rm -f $i
done
#####
##### Easier way to remove too many files right from command line
#####

ls|xargs rm -f

Tags: , ,

Reply

Copyright © 2012 BenMcGrail.com All rights reserved.
Hosted by: VitexOnline.com