[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Parsing a file name in the shell



Ron Mullins wrote:
> 
> Can someone help me this? We run a FTP server that has constant
> scriptkiddie activity, i.e. uploading of warez. I would like to automate
> the removing of directories, as they are always a number, but I can't
> figure out how to test whether the name is or starts with a number.

I think
   find ftp-root -type d -path "*/[0-9]*"

will give you a list of directories starting with digits which you can
pipe to xargs for removal, something like:

   find ftp-root -type d -path "*/[0-9]*" |xargs rm -fr
or perhaps
   find ftp-root -type d -path "*/[0-9]*" -print0 |xargs -0 rm -fr


  You should really test it seriously though, and (probably read the
manpages for find and xargs) as it's more or less right out of my head.

***
Beware that the list (if working;-) will contain ALL directories bellow
"ftp-root" starting with one or more digits, are you sure that none of
the is a valid upload?
***

Best regards,
	Emil



Reply to: