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

Re: delete n files in a directory



On Sat, Jun 16, 2001 at 10:08:14AM +0000, Mário Henrique Cruz Tôrres wrote:
>     Good morning everyone. I wan't know if can I delete the first 200
> files ( in alphabetical order ) in a directory wich have
> 300 files ?
>     I'm using bash shell.

you can use xargs (as you've been told already), but I find it's
a pain when you have filenames with spaces, apostrphes, stuff
like that. I'd probably do something like

j=0; for i in *; do j=$((j+1)); rm -v "$i"; [ $j -eq 200 ] && exit; done

-- 
John Lenton (john@grulic.org.ar) -- Random fortune:
SCCS, the source motel!  Programs check in and never check out!
		-- Ken Thompson

Attachment: pgp36bi3Jr2yx.pgp
Description: PGP signature


Reply to: