0

Other than rm, what alternative methods will achieve the same result?

For example, moving a file to "trash" and securely emptying the trash bin. Or moving the file to /dev/null

  • 3
    unlink filename – Ramesh Jun 2 '15 at 4:19
  • 4
    @1"; Note that you cannot remove a file using /dev/null; the latter is primarily used to discard output from processes using redirection. – Janis Jun 2 '15 at 4:50
  • Overwrite with another file: mv 16tons filename – yaegashi Jun 2 '15 at 5:20
  • 2
    find filename -delete – yaegashi Jun 2 '15 at 6:02
  • Actually not an answer since the file remains but with > filename you can empty/truncate the file to 'trash' its contents – Lambert Jun 2 '15 at 8:19
1

There are lots of utilities that can delete a file, perl or other language interpreters are obvious candidates. If you have gcc, you can make yourself another one:

echo "main(int argc, char **argv) {return unlink(argv[1]);}" > myrm.c && gcc myrm.c -o myrm && ./myrm myrm.c
  • Love it! Let's call it jit-rm :D . – user86969 Jun 2 '15 at 7:49
0

The command will delete all the files inside /foo directory:

find /foo -type f -exec rm {} \;
  1. Find all the files in foo directory
  2. Execute the files that was found
  3. Remove them one by one

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.