The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



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 !!

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 02:02 AM
dash after ampersant csecnarf UNIX for Dummies Questions & Answers 2 03-12-2008 03:47 PM
wc of characters in a file ignoring white space sachin.gangadha UNIX for Dummies Questions & Answers 1 12-15-2007 06:13 PM
double-dash options dhinge Shell Programming and Scripting 1 01-10-2007 10: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 12:28 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-04-2008
LumpSum LumpSum is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 2
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?
  #2 (permalink)  
Old 08-04-2008
Yogesh Sawant's Avatar
Yogesh Sawant Yogesh Sawant is offline Forum Staff  
Part Time Moderator and Full Time Dad
  
 

Join Date: Sep 2006
Location: Rossem, Tazenda
Posts: 1,086
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
  #3 (permalink)  
Old 08-04-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
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 (permalink)  
Old 08-04-2008
LumpSum LumpSum is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 2
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
  #5 (permalink)  
Old 08-04-2008
broli's Avatar
broli broli is offline
Registered User
  
 

Join Date: Dec 2007
Location: Argentina
Posts: 215
and what about using \ ?

mv \-x x <---
  #6 (permalink)  
Old 08-04-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
broli: it's the same as quoting; it only prevents interpretation by the shell.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:57 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0