How To Remove files starting with -


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users How To Remove files starting with -
# 1  
Old 09-29-2004
Question How To Remove files starting with -

In Unix/Linux when u create a file starting with a - e.g.-file
then when u try to remove or rename it, it is not possible.
e.g. rm -file . when we give this command rm assumes to be its option rather than its argument. Same is the case when this filename is given as an argument to mv or cat and other commands.

Can any1 provide a solution??
# 2  
Old 09-29-2004
This is a very common question

rm -- -file

The "--" tells rm (and many other *nix commands) to stop interpreting arguments as options, and to treat them as filenames.

Cheers
ZB
# 3  
Old 09-29-2004
You can also prefix a 'goofy' filename with the path
Code:
rm -f /home/usr/-file

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Need to remove lines starting with an ID from all fine in a director

Hi All, I have almost 200 files in a directory I want to remove all lines in each file that is starting with 88002 and 88003. I tried with grep -v and if I plan to do that I need to for all the files individually and it is 200+ files. Any way I can do at single command ... (4 Replies)
Discussion started by: arunkumar_mca
4 Replies

2. Shell Programming and Scripting

Shellscript command to remove files starting with a certain string, and older than 3 days

Hi All, Need help in identifying a shellscript command to remove all files on a server directory, starting with a certain prefix and also older than 3 days. That means files created with that prefix, today or yesterday, shouldn't be removed. Thanks, Dev (3 Replies)
Discussion started by: dev.devil.1983
3 Replies

3. Shell Programming and Scripting

Remove duplicate line starting with a pattern

HI, I have the below input file /* ----------------- cmdsDlyStartFWJ -----------------*/ UNIX_JOB CMDS065J RUN ANY CMDNAME sleep 5 AGENT CMDSHP USER proddata RUN MON,TUE,WED,THU,FRI DELAYSUB 02:00 /* "Triggers daily file watcher jobs" */ ENVAR... (5 Replies)
Discussion started by: varun22486
5 Replies

4. Shell Programming and Scripting

how to remove a variable starting with dot using sed command

Hi, I want to remove a variable starting with dot(.) in a file using sed command. aaa sss .abc s/^\.abc/d I tried this but it didnt worked. (5 Replies)
Discussion started by: vdhingra123
5 Replies

5. Shell Programming and Scripting

Remove line starting from space till end.

Hi, I have a code tag, from which i have the below snippet: intelrpt.GetCMB_FB type=ODBC> intelrpt.GetCMB_FB type=SYBASE> I want the output like: intelrpt.GetCMB_FB intelrpt.GetCMB_FB That is remove the lines starting from WHITESPACE till end. Please help. I am new to... (7 Replies)
Discussion started by: anupdas
7 Replies

6. Shell Programming and Scripting

remove lines starting with

Hi I have an input file... /* ----------------- AGYDLY_Box ----------------- */ insert_job: AGYDLY_Box job_type: b owner: spdrdev permission: gx,wx date_conditions: 1 days_of_week: mo,tu,we,th,fr exclude_calendar: mtg_holidays start_times: "1:00" description: "Process Daily New pools... (2 Replies)
Discussion started by: ramky79
2 Replies

7. Shell Programming and Scripting

How to remove all words starting from a matching word in a line

Hi Guys, I have a file like this: wwwe 1 ioie ewew yyy uuu 88 erehrlk 4 ihoiwhe lkjhassad lkhsad yyy mmm 45 jhash lhasdhs lkhsdkjsn ouiyrshroi oihoihswodnw oiyhewe yyy ggg 77 I want to remove everything after "yyy" and including "yyy" from each line in the file. So I want:... (2 Replies)
Discussion started by: npatwardhan
2 Replies

8. Shell Programming and Scripting

Remove field starting with * and #

Hi i have file with data: abc,*xyz,#abc 123,#123,1234 *123,#123,abc So i want to remove only fields starting with * and # and i want output as: abc,, 123,,1234 ,,abc Please suggest something Thanks Sumit (3 Replies)
Discussion started by: sumit207
3 Replies

9. UNIX for Dummies Questions & Answers

remove lines in text starting with . (period)

how can i remove lines from a text file starting with . (a period) (11 Replies)
Discussion started by: Movomito
11 Replies

10. Shell Programming and Scripting

How to remove files starting with -

Hi, Can anyone suggest me how to remove the file whose name starts with "-". Say i have a file by name -out. I want to remove this. I tried escaping -, but didnt work. I work on AIX 5.3 machine. Thanks in advance. Suman (5 Replies)
Discussion started by: suman_jakkula
5 Replies
Login or Register to Ask a Question