ignoring a dash in file name

Tags
beginners, file, file name

 

 
Thread Tools Search this Thread
# 1  
Old 08-04-2008
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  
Old 08-04-2008
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  
Old 08-04-2008
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  
Old 08-04-2008
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  
Old 08-04-2008
and what about using \ ?

mv \-x x <---
# 6  
Old 08-04-2008
broli: it's the same as quoting; it only prevents interpretation by the shell.
 

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Ignore all lines except the --- dash line in a text file. dellanicholson UNIX for Dummies Questions & Answers 3 09-07-2015 05:44 AM
AIX : Find files ignoring certain file extensions kavinmjr AIX 4 06-24-2015 03:38 PM
Compute average ignoring outliers of different segments within a dat file using awk malandisa Shell Programming and Scripting 7 09-19-2014 06:58 PM
Ignoring lines and create new file callmatkarna Shell Programming and Scripting 4 02-21-2013 11:46 AM
Want a tcl script to compare a string in a file ignoring white spaces kulua Post Here to Contact Site Administrators and Moderators 1 04-30-2012 11:07 AM
Deleting all files recursively from directories while ignoring one file type pasc Shell Programming and Scripting 3 10-16-2011 09:19 AM
Extracting string before first dash in a file name bashnewbee Shell Programming and Scripting 2 07-11-2011 01:10 PM
using diff to on two file but ignoring the last comma separate value wny201 Shell Programming and Scripting 1 04-21-2011 04:04 PM
Ignoring file name case and decrypting it. anushree.a Shell Programming and Scripting 6 12-14-2010 07:50 AM
ignoring lines in a file thelakbe Shell Programming and Scripting 2 10-28-2010 04:17 AM
How to extract a string from a file ignoring new line suresh_kb211 Shell Programming and Scripting 3 08-04-2009 06:31 AM
File Comparison command but ignoring while spaces Veenak15 Shell Programming and Scripting 7 07-10-2009 11:21 AM
ignoring blank line in a file ali560045 Shell Programming and Scripting 4 11-12-2008 05:23 AM
wc of characters in a file ignoring white space sachin.gangadha UNIX for Dummies Questions & Answers 1 12-15-2007 06:13 PM