The blog provides Network Security Tips, Tricks, How To/Procedures. Products and areas not limited to Firewalls, Security, Check Point, Cisco, Nokia IPSO, Crossbeam, SecurePlatform, SPLAT, IP Appliance, GAiA, Unix/Linux.

Linux/Unix - How To Remove/Delete File

In Linux/Unix, based system one or more file can be removed using "rm" command.


Syntax:

rm [OPTION]... FILE...

Option:
  -f, --force ignore nonexistent files, never prompt
  -i          prompt before every removal
  -I          prompt once before removing more than three files, or
              when removing recursively.  Less intrusive than -i,
              while still giving protection against most mistakes


      --interactive[=WHEN]  prompt according to WHEN: never, once   

              (-I), or always (-i).  Without WHEN, prompt always

      --one-file-system when removing a hierarchy recursively, skip 

              any directory that is on a file system different from
              that of the corresponding command line argument


      --no-preserve-root  do not treat `/' specially
      --preserve-root   do not remove `/' (default)


  -r, -R, --recursive remove directories and their contents 

                      recursively

  -v, --verbose  explain what is being done
      --help     display this help and exit
      --version  output version information and exit



Example:

[root@linux]# rm file1
rm: remove regular empty file `file1'? y
[root@linux]#


!! Removing/deleting multiple files !!

[root@linux]# rm file2 file3
rm: remove regular empty file `file2'? y
rm: remove regular empty file `file3'? y
[root@linux]#


!! Removing/deleting file with "-f" force option / never prompt option !!


[root@linux]# rm -f file4
[root@linux]#




Linux/Unix - How To Remove/Delete File Linux/Unix - How To Remove/Delete File Reviewed by Admin on 13:06:00 Rating: 5