home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam    

UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 23.13 Deleting Files with the Null Name Chapter 23
Removing Files
Next: 23.15 Using unlink to Remove a File with a Strange Name
 

23.14 Handling a Filename Starting with a Dash (-)

Sometimes you can slip and create a file whose name starts with a dash ( - ), like -output or -f . That's a perfectly legal filename. The problem is that UNIX command options usually start with a dash ( - ). If you try to type that filename on a command line, the command might think you're trying to type a command option.

In almost every case, all you need to do is "hide" the dash from the command. Start the filename with ./ (dot slash). This doesn't change anything as far as the command is concerned; ./ just means "look in the current directory" ( 1.21 ) . So here's how to remove the file -f :

% 

rm ./-f

(Most rm commands have a special option for dealing with filenames that start with a dash, but this trick should work on all UNIX commands.)

- JP


Previous: 23.13 Deleting Files with the Null Name UNIX Power Tools Next: 23.15 Using unlink to Remove a File with a Strange Name
23.13 Deleting Files with the Null Name Book Index 23.15 Using unlink to Remove a File with a Strange Name

The UNIX CD Bookshelf Navigation The UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System










??????????????@Mail.ru