|
Search Forums:
|
|||||||
| Forums | Register | Forum Rules | Linux and Unix Links | Man Pages | Albums | FAQ | Users | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
ignoring a dash in file name
so i have a simple file called -x and i need it renamed to x now i dont understand why when using the most basic methods, only the code Code:
mv ./-x x changes the file name while using any other type of escape characters around the dash, such as single/double quotations or backslash, doesnt. anyone? im completely new to unix and this seems out of the ordinary. im sure there is a very obvious answer to this shouldnt things like mv /-/x x or mv "-"x x work? |
| Sponsored Links | |
|
|
|
#2
|
||||
|
||||
|
mv -x x passes option -x to command mv. that is not what you are intended to do
mv ./-x x does the job - since you mentioned relative path, which solved the "passing option to the command" problem |
| Sponsored Links | ||
|
|
|
#3
|
|||
|
|||
|
Quoting is to prevent interpretation by the shell, whereas option processing is handled by the program itself. The shell strips and discards quotes, so mv doesn't even see a difference between "-"x and -x (and /-/x is, frankly, neither here nor there).
|
|
#4
|
|||
|
|||
|
i see, thank both of you for clearing this up for me, it is very much appreciated
im sure ill run into you lot more as i go on and on with unix. im the definition of noob at the moment |
| Sponsored Links | |
|
|
#5
|
||||
|
||||
|
and what about using \ ?
mv \-x x <--- |
| Sponsored Links | |
|
|
#6
|
|||
|
|||
|
broli: it's the same as quoting; it only prevents interpretation by the shell.
|
| Sponsored Links | ||
|
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| gethostbyname_r returns NULL when hostname has dash | uunniixx | IP Networking | 12 | 06-04-2008 01:02 AM |
| dash after ampersant | csecnarf | UNIX for Dummies Questions & Answers | 2 | 03-12-2008 02:47 PM |
| wc of characters in a file ignoring white space | sachin.gangadha | UNIX for Dummies Questions & Answers | 1 | 12-15-2007 05:13 PM |
| double-dash options | dhinge | Shell Programming and Scripting | 1 | 01-10-2007 09:32 PM |
| How to remove a file with a leading dash '-' in it's name? | GSalisbury | UNIX for Advanced & Expert Users | 3 | 05-05-2003 11:28 AM |
|
|