Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Can you explain? I feel like it removes / but not sure why.


   rm -rf /path/to/delete/ *
Note the space between the last / and the *

This will recursively remove the directory /path/to/delete and remove every file/directory that matches * in the current directory where 'rm' is being run.

When what was most likely meant was:

   rm -rf /path/to/delete/*
Note the lack of a space between the last / and . This will remove all files that match that reside in the /path/to/delete/ directory.


Besides recursively deleting /path/to/delete/ the command also deletes all (non hidden) content of the current directory (note the * at the end of the line). I assume the correct command would be /path/to/delete/*.


The error is the space before the asterisk. The original intention was to delete the contents of the folder /path/to/delete/. Instead, the asterisk enumerates files in the current directory and they get deleted


It removes everything in the current directory




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: