Re: Suggestions for rm [WAS: Re: Feature request: install package by passing URL to apt-get]
On Fri, Jun 24, 2022 at 07:02:35AM +0000, Andrew M.A. Cater wrote:
> There are a couple of useful habits to get into when removing things:
>
> There's an
>
> rm -i
> Use the pwd command to check where you are in the
> filesystem. (It may be short for "print working
> directory").
> If you are deleting one file - change to the directory it is in, check that
> it exists there first with the
>
> ls -al [filename]
>
> command. Since the file is in the current directory,you can use the
>
> rm ./[filename]
>
> [That's a period and a forward slash - limiting you to a file in the current
> directory]
>
> Try and avoid using rm -rf and forced removal. The one exception is that
> you have to remove a non-empty directory with -rf. If you first try -r
> and it fails, that's a clue that you are actually about to delete a
> directory.
>
> Again, if it's a single directory, change directories to the directory
> that it is in and use the ./ The last suggestion, and it's the simplest:
>
> rm [filename] -rf
...
> If you need to be doubly sure rm [filename] -irf will put in the interactive
> prompt again.
>
> Some of this is learnt the hard way from administering one machine that
> other people relied on :)
All good suggestions, along with making backups.
I list the files first:
ls some-pattern
then add a pipe to rm:
ls some-pattern | rm
or
ls some-pattern | rm -rf
I know the OP said they weren't asking advice, but I can't
help putting in my two bits :-)
cheers,
> With every good wish, as ever,
>
--
Joel Roth
Reply to: