Thursday, June 30, 2011

Deleting files with rm command

You remove files at the prompt by using the pm command, like so

$ rm my_copy.txt


In order to remove a directory and everything in it, we must ass the "recursive" flag (-r)

$ rm -r my_dir


Normally we must have write permission in order to delete it; however, if you have write permissions on the directory containing the file, we can if we confirm the action! 
If you attempt to delete a file you don´t have read permissions, you´ll be asked if you really want to deleter it.


To force a deletion without further cocnfirmation, add th -f flag to the comand, like so:



$ rm -rf _my_dir/my_copy.txt

No comments:

Post a Comment