Delete Unix File with Special Characters - Unix Commands

This is a discussion on Delete Unix File with Special Characters - Unix Commands ; We keep getting this question on how to delete a file with special or strange or hidden characters very often. Lets take for example that you have a file with name "-file" or something like "*file" etc. For any normal ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: Delete Unix File with Special Characters

  1. Post Delete Unix File with Special Characters

    We keep getting this question on how to delete a file with special or strange or hidden characters very often. Lets take for example that you have a file with name "-file" or something like "*file" etc.

    For any normal file, its important to take a back up of the file before any delete attempts are made. In particular we recommend the usage of command "rm -i" to allow for interactive prompt of the file name before being deleted.

    Now to deleting files with special characters in its name..

    Assume filename of the file you want to delete is "-file", then the command to execute is
    Code:
     rm -f  '-file'
    .

    If you want to first move that file into a normal file name you can also use the mv command as
    Code:
     mv '*file' normalfile
    . Now you can use the normal rm command to remove the file.

  2. Re: Delete Unix File with Special Characters

    For deleting the Unix File Do Following:
    1) Create a hard to delete file name.
    2) Try to remove this file with rm command.
    3) Remove file by an inode number, but first find out the file inode number.
    fathers day

+ Reply to Thread