Saturday, July 26, 2014

rm command in linux/unix

  1. Use the rm command to delete a file. List your directory after the command completes.
    
         rm new.config
         ls
         
  2. cd to another subdirectory say, subdir2. List the directory to view its contents. Then use the "*" wildcard to remove all of the files. NOTE: using rm in this manner can be dangerous! If you are in the wrong directory, you'll remove files you didn't mean to remove. You may want to use the -i option to protect yourself from accidents.
    
         cd subdir2
         ls
         rm -i *
         ls
         
  3. Get out of the subdir2 subdirectory by using the command cd .. Now try to use rm to remove a directory. What happens?
    
         cd ..
         rm subdir3
         
  4. This time, include the -r option when you try to remove a directory. For example, try removing some subdirectory subdir3. What happens?
    
         rm -r subdir3
         ls
         

Reactions:

0 comments:

Post a Comment