ßÏßÏÊÓƵ

print friendly version

Questions and answers

171
How do I delete files like: *.;1 on the ITS Unix system?


The commands described below need to be entered while logged in to the Unix server.   Normally you'll see a prompt ending with $ when the command interpreter (or shell) is ready for another command.

Suppose you have a file :-

foo.tmp;2

To remove the file, give the command

rm foo.tmp\;2

will remove it - the backslash (\) is called an escape character, used to prevent the character after it (; in this case) from being interpreted as part of the command. For the above example you could also do

rm foo.tmp?2

(the question-mark (?) character is interpreted as meaning "any single character").

More generally, if you can find a pattern that finds only the files you want to delete you can use that. For example, suppose that all the files with strange characters also contain the letters foo, then the following command should do the trick:

rm *foo*

The * characters are called wildcards. You have to be very careful when using wildcards. In the previous example, all file names containing foo would be deleted. It's best to use ls to check before you do rm. In the previous example you would do :-

ls *foo*

first, just to check there weren't any files you'd forgotten about.

Help us to improve this answer

Please suggest an improvement
(login needed, link opens in new window)

Your views are welcome and will help other readers of this page.

Categories

This is question number 171, which appears in the following categories:

Created by Andy Clews on 27 July 2001 and last updated by Andy Clews on 4 August 2015