We usually find files that were created accidentally, that was named starting with hyphens, like -filename.
You cannot simply type rm -filename as the command line parser treats the filename as a command line switch. There are other characters that work the same way, like #, which gets created by some text editors as a backup file, e.g., #myfile#.
A simple way to delete these files is to find another way to access them so the special character isnt the first character after the whitespace. This can be done by referencing them via their path location, or most simply by preceding the filename with ./ which is the current directory.
The files in the above examples can be deleted with the following commands:
$ rm ./--filename
$rm ./#myfile#
You can also delete files having special name in their filenames with inode number.
Ex:
> ls -li ==> first column is inode num
> find . -inum -exec rm {} ;
You cannot simply type rm -filename as the command line parser treats the filename as a command line switch. There are other characters that work the same way, like #, which gets created by some text editors as a backup file, e.g., #myfile#.
A simple way to delete these files is to find another way to access them so the special character isnt the first character after the whitespace. This can be done by referencing them via their path location, or most simply by preceding the filename with ./ which is the current directory.
The files in the above examples can be deleted with the following commands:
$ rm ./--filename
$rm ./#myfile#
You can also delete files having special name in their filenames with inode number.
Ex:
> ls -li ==> first column is inode num
> find . -inum -exec rm {} ;
No comments:
Post a Comment