Problem deleting file with special character


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Problem deleting file with special character
# 1  
Old 12-07-2005
Problem deleting file with special character

I'm having problems deleting a file with a special character and I'm hoping that somebody here can help. The file "-osample1.c" will not remove from my directory. Here is an example of what happens. Any ideas would be appreciated.

> ls *sample1*
ls: illegal option -- .
usage: ls -1ARadeCxmnlogrtucpFLbqisf [files]
> ls
-osample1.o demo_proc.mk makefile test.sh test1.c test1.o testing
asdf.log inst scripts test1 test1.lis test1.pc
> rm *sample1*
rm: illegal option -- o
rm: illegal option -- s
rm: illegal option -- a
rm: illegal option -- m
rm: illegal option -- p
rm: illegal option -- l
rm: illegal option -- e
rm: illegal option -- 1
rm: illegal option -- .
rm: illegal option -- o
Usage: rm [-Rfir] file ...
> rm -osample1.o
rm: illegal option -- o
rm: illegal option -- s
rm: illegal option -- a
rm: illegal option -- m
rm: illegal option -- p
rm: illegal option -- l
rm: illegal option -- e
rm: illegal option -- 1
rm: illegal option -- .
rm: illegal option -- o
Usage: rm [-Rfir] file ...
# 2  
Old 12-07-2005
From man sh

Code:
       --        A -- signals the end of options and disables  further  option
                 processing.   Any arguments after the -- are treated as file-
                 names and arguments.  An argument of - is equivalent to --.

Look at this

Code:
sh-2.05b$ touch -- -123
sh-2.05b$ ls -l -- -123
-rw-r--r--    1 abcdefgh g900            0 Dec  7 07:17 -123
sh-2.05b$ rm  -- -123
sh-2.05b$ ls -l -- -123
ls: -123: No such file or directory
sh-2.05b$

# 3  
Old 12-07-2005
Worked like a charm Smilie Thanks for the help Vino!
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Red Hat

Special character ^@ in CSV file

All, I am having a tough time with Linux and CSV file. My CSV file gets generated from Cognos on Linux machine that contains special characters. At first instance when I do vi <filename> to that file, I can't see anything. I did tail -2 and redirected to another temp file and did vi <filename>,... (2 Replies)
Discussion started by: donadarsh
2 Replies

2. Programming

Problem with control file and special character

I am getting error when loading data file using ctl file. I get this error only when there is special character. Below is some data. DataFile=> company_id|ciu_id|english_name|iso_country_code|active|partner_name 1-2JT-122||Expert Järvenpää|FI|A|Expert Järvenpää Control File=> LOAD DATA... (1 Reply)
Discussion started by: rshivarkar
1 Replies

3. Shell Programming and Scripting

Removing Special Character from File.

Hi, My file has this special character "^M" I would like to remove this characters. eg: abc,abc,^M i tried using sed but doesnt work. i used octal dump command to see special character it returns following: 015 \r Appreciate your reply. (6 Replies)
Discussion started by: pinnacle
6 Replies

4. Shell Programming and Scripting

Deleting all characters from 350th character to 450th character from the log file

Hi All, I have a big log file i want to delete all characters (between 350th to 450th characters) starting at 350th character position to 450th character position. please advice or sample code. (6 Replies)
Discussion started by: rajeshorpu
6 Replies

5. Shell Programming and Scripting

parse a file for a special character

hello, How to parse a file to see if a specific line is commented by '#' character? filename: file1 cat file1 ... # /usr/bin/whatever ... thank you (9 Replies)
Discussion started by: melanie_pfefer
9 Replies

6. Shell Programming and Scripting

deleting a special file

Hi, I have FTP'd a file two times from windows to unix machine. The second file is coming as bbmenu (2). I want to delete this file but it is not getting deleted. Kindly let me know the way how i can do that. Thanks Namish (2 Replies)
Discussion started by: namishtiwari
2 Replies

7. UNIX for Dummies Questions & Answers

Special character in my file

I have a special character in my file. It displays as a '#' sign but when I do this command I do not find the line. fgrep 'G#ant' file1 I want to replace the special character with another value but I need to know what character it really is. Any ideas on how to replace this '#' value with... (3 Replies)
Discussion started by: Ryan2786
3 Replies

8. Shell Programming and Scripting

delete a special character in file

hi i want to delete a particular character in file. example file name:abcsample abc=bbbqw3/ hidh=ajjqiwio4/ xyx=hakjp/ ........../ ......./ i want to delete that special character (/) in abcsample file Permnently.please give the required commands for my requirement. required... (1 Reply)
Discussion started by: srivsn
1 Replies

9. Shell Programming and Scripting

delete a special character in file

hi i want to delete a particular character in file. example file name:abcsample abc=bbbqw3/ hidh=ajjqiwio4/ xyx=hakjp/ ........../ ......./ i want to delete that special character (/) in abcsample file.please give the required commands for my requirement. thank you (3 Replies)
Discussion started by: srivsn
3 Replies
Login or Register to Ask a Question