What is the command to delete all files in a directory?
Jun 6, 1999, 4:39 AM
Veteran (3111 posts)
Jun 6, 1999, 4:39 AM
Post #2 of 4
Views: 3710
From perldoc -f unlink:
unlink Deletes a list of files. Returns the number of files successfully deleted.
$cnt = unlink 'a', 'b', 'c';
unlink @goners;
unlink <*.bak>;
Note: `unlink()' will not delete directories unless you are superuser and the -U flag is supplied to Perl. Even if these conditions are met, be warned that unlinking a directory can inflict damage on your filesystem. Use `rmdir()' instead.
If LIST is omitted, uses `$_'.
I hope this helps.
[This message has been edited by Bobsie (edited June 06, 1999).]
Quote:
unlink LIST unlink Deletes a list of files. Returns the number of files successfully deleted.
$cnt = unlink 'a', 'b', 'c';
unlink @goners;
unlink <*.bak>;
Note: `unlink()' will not delete directories unless you are superuser and the -U flag is supplied to Perl. Even if these conditions are met, be warned that unlinking a directory can inflict damage on your filesystem. Use `rmdir()' instead.
If LIST is omitted, uses `$_'.
I hope this helps.
[This message has been edited by Bobsie (edited June 06, 1999).]