Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

remove files smaller 36Kb

Status
Not open for further replies.

Currando

ISP
Feb 13, 2001
25
ES
Hi,

I need a program that find the files in a directory smaller that 36KB and remove this files.

I make this line for this:

ls -l | awk '{print $5,$9}'|grep \^36 | awk '{print "rm",$2}' | sh

Anybody make this with less commands

Thanks
 
Hi, Currando!

Please, try this command:

ls -l | awk '$5 > 36000 { print "rm", $9 }' | sh

Instead number 36000 you can put other number .

Bye!

KP. =-)
 
You could use the unix find command to do this, e.g.

find . -type f -size -71 -exec rm {} \;

will find all files within (and under) your current directory with a size of 71 blocks or less (1 block=512 bytes, so 71 blocks is roughly 36Kb) and remove them.

Bear in mind that this commmand searches directories recursively from the start directory!!

If you just want to list the files it finds first to be sure, you can use the command

find . -type f -size -71 -exec ls -l {} \;

Greg.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top