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

Re: Parsing a file name in the shell



How about this?

aperrin@hm269-26876:~/tmp$ ls
aperrin@hm269-26876:~/tmp$ touch 1foo
aperrin@hm269-26876:~/tmp$ touch 2foo
aperrin@hm269-26876:~/tmp$ touch foo
aperrin@hm269-26876:~/tmp$ ls -la
total 12
drwxr-sr-x    2 aperrin  aperrin      4096 Feb  6 11:18 .
drwxr-sr-x   49 aperrin  aperrin      8192 Feb  6 08:51 ..
-rw-r--r--    1 aperrin  aperrin         0 Feb  6 11:17 1foo
-rw-r--r--    1 aperrin  aperrin         0 Feb  6 11:18 2foo
-rw-r--r--    1 aperrin  aperrin         0 Feb  6 11:18 foo
aperrin@hm269-26876:~/tmp$ rm -f {1,2,3,4,5,6,7,8,9,0}foo
aperrin@hm269-26876:~/tmp$ ls -la
total 12
drwxr-sr-x    2 aperrin  aperrin      4096 Feb  6 11:18 .
drwxr-sr-x   49 aperrin  aperrin      8192 Feb  6 08:51 ..
-rw-r--r--    1 aperrin  aperrin         0 Feb  6 11:18 foo


Note the rm -rf line, which does what you're asking. But note also that
script kiddies may be capable of generating other devious filename
patterns, including those that start with . .

Best,
Andy Perrin

----------------------------------------------------------------------
Andrew J Perrin - andrew_perrin@unc.edu - http://www.unc.edu/~aperrin
 Assistant Professor of Sociology, U of North Carolina, Chapel Hill
      269 Hamilton Hall, CB#3210, Chapel Hill, NC 27599-3210 USA


On 6 Feb 2002, 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.
> 
> Does anyone have some good ideas or experience with this? Shell
> scripting isn't one of my strong points. The server is Debian Woody.
> Please CC me as I am not currently subscribed to the list.
> 
> P.S. I'm using Pure-FTP and have it setup so that the Warez cannot be
> downloaded, so they can't get it back off, but it is annoying to have to
> do this manually. Annonymous uploads are needed so I can't turn that
> feature off. Thanks in advance.
> 
> -- 
> Ron Mullins
> DigiTerra, Inc.
> IT Network Engineer
> Email: rmullins@digiterra.com
> Phone: 219-247-4870
> 
> 
> -- 
> To UNSUBSCRIBE, email to debian-user-request@lists.debian.org 
> with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
> 
> 



Reply to: