[X-Unix] Trying to get rid of unwanted files

David Ledger dledger at ivdcs.demon.co.uk
Sat May 15 07:14:57 PDT 2004


>From: Mark Gibson <gibsonm at bigpond.net.au>
>
>My concern is that there seems to be an upper limit to the number of
>files that rm can cope with.

The shell command line has a maximum length.  The shell expands the 
'*' to be a list of all files & directories except those starting 
with a '.'.  If the the result of that expansion is too big, the rm 
command doesn't get run.  The shorter your average filename, the more 
of them you can rm at once.

	cd  /var/spool/cups
	pwd	# to make sure you're in the right place
	ls | xargs rm

will do any number (man xargs).  Non-interactive version:

	cd  /var/spool/cups && ls | xargs rm

the command after the '&&' isn't run if the cd failed (because you 
typed it wrong, and you're still where you were).

David


>Hopefully running this script daily will keep the number of files in
>/cups beneath that.
>
>I know I have to use a different approach in /tmp because the files
>there can reach several thousands in a 24 hr period.

-- 
David Ledger - Freelance Unix Sysadmin in the UK.
Chair of HPUX SysAdmin SIG of hpUG technical user group (www.hpug.org.uk)
dledger at ivdcs.co.uk (also dledger at ivdcs.demon.co.uk)
www.ivdcs.co.uk



More information about the X-Unix mailing list