|
INTERVIEW QUESTIONS
OPERATING SYSTEMS
UNIX PROGRAMMING
DETAILS
Question: How do I remove a file whose name begins with a "-" ?
Answer: Figure out some way to name the file so that it doesn't begin with a dash. The simplest answer is to use rm ./-filename (assuming "-filename" is in the current directory, of course.) This method of avoiding the interpretation of the "-" works with other commands too.
Many commands, particularly those that have been written to use the "getopt(3)" argument parsing routine, accept a "--" argument which means "this is the last option, anything after this is not an option", so your version of rm might handle "rm -- -filename". Some versions of rm that don't use getopt() treat a single "-" in the same way, so you can also try "rm - -filename".
|
|
|
Category |
Unix Programming Interview Questions & Answers -
Exam Mode /
Learning Mode
|
Rating |
(0.3) By 6911 users |
Added on |
8/26/2014 |
Views |
71723 |
Rate it! |
|
|
Question:
How do I remove a file whose name begins with a "-" ?
Answer:
Figure out some way to name the file so that it doesn't begin with a dash. The simplest answer is to use rm ./-filename (assuming "-filename" is in the current directory, of course.) This method of avoiding the interpretation of the "-" works with other commands too.
Many commands, particularly those that have been written to use the "getopt(3)" argument parsing routine, accept a "--" argument which means "this is the last option, anything after this is not an option", so your version of rm might handle "rm -- -filename". Some versions of rm that don't use getopt() treat a single "-" in the same way, so you can also try "rm - -filename". Source: CoolInterview.com
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|
|
Related Questions |
View Answer |
|
What happened to the pronunciation list that used to be part of this document?
|
View Answer
|
|
What are some useful Unix or C books?
|
View Answer
|
|
How does the gateway between "comp.unix.questions" and the "info-unix" mailing list work?
|
View Answer
|
|
What does {some strange unix command name} stand for?
|
View Answer
|
|
When someone refers to 'rn(1)' or 'ctime(3)', what does the number in parentheses mean?
|
View Answer
|
|
Who helped you put this list together?
|
View Answer
|
|
Describe about awk and sed?
|
View Answer
|
|
Explain the basic forms of each loop?
|
View Answer
|
|
Explain about the case statement.
|
View Answer
|
|
What is a FIFO?
|
View Answer
|
|
Brief about the directory representation in UNIX
|
View Answer
|
|
What is 'inode'?
|
View Answer
|
|
How are devices represented in UNIX?
|
View Answer
|
|
Why use _exit rather than exit in the child branch of a fork?
|
View Answer
|
|
What's the difference between fork() and vfork()?
|
View Answer
|
|
What does fork() do?
|
View Answer
|
|
Create your own shell that completes the following problem: Ask the user their name, Compare it to your name, Give a reply that their response is either your name too or it is a nice name too
|
View Answer
|
|
If you want to migrate a 32 bit application to a 64 bit os, what all would you check
|
View Answer
|
|
How do you debug a core dump
|
View Answer
|
|
How would you create shared and dynamic libraries
|
View Answer
|
Please Note: We keep on updating better answers to this site. In case you are looking for Jobs, Pls Click Here Vyoms.com - Best Freshers & Experienced Jobs Website.
View All Unix Programming Interview Questions & Answers - Exam Mode /
Learning Mode
|