Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to
LinuxQuestions.org , a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free.
Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please
contact us . If you need to reset your password,
click here .
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
11-23-2009, 01:57 PM
#1
Member
Registered: Nov 2007
Posts: 108
Rep:
problem with mv and cp
when I try to do mv *.txt /some/directory/
I get
mv: invalid option -- 'd'
Try `mv --help' for more information.
Then when I try cp *.txt /some/directory/
I get
cp: invalid option -- 'e'
Try `cp --help' for more information.
I tried this with zsh and bash with the same result.
Not sure what's changed but doesn't seem like anything wrong
with my syntax.
I'm running 64bit gentoo.
11-23-2009, 02:00 PM
#2
Senior Member
Registered: Dec 2008
Location: Independance, OH
Distribution: Debian, CentOS, Slackware, RHEL, Gentoo
Posts: 1,833
Rep:
Try:
If they show up as having an alias you can unalias them via:
Code:
unalias mv
unalias cp
Edit: Might also want to run rkhunter and chkrootkit to be on the safe side.
Last edited by rweaver; 11-23-2009 at 02:02 PM .
11-23-2009, 02:03 PM
#3
Member
Registered: Nov 2007
Posts: 108
Original Poster
Rep:
No, I don't believe either one of those commands is aliased:
alias<ENTER> gives:
alias grep='grep --colour=auto'
alias ll='ls -lh'
alias ls='ls --color=auto'
Quote:
Originally Posted by
rweaver
Try:
If they show up as having an alias you can unalias them via:
Code:
unalias mv
unalias cp
Edit: Might also want to run rkhunter and chkrootkit to be on the safe side.
11-23-2009, 02:07 PM
#4
Guru
Registered: Nov 2005
Location: Pasadena, CA
Distribution: Arch+KDE
Posts: 16,552
what is in the source directory? It seems that something is being substituted for "*" that mv and cp read as option flags.
11-23-2009, 02:11 PM
#5
Member
Registered: Nov 2007
Posts: 108
Original Poster
Rep:
I'm trying to move several files that share the same extension and are located in my home directory(~/*.txt). The destination is the ~/Desktop
Quote:
Originally Posted by
pixellany
what is in the source directory? It seems that something is being substituted for "*" that mv and cp read as option flags.
11-23-2009, 02:13 PM
#6
Senior Member
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,421
11-23-2009, 02:14 PM
#7
Guru
Registered: Nov 2005
Location: Pasadena, CA
Distribution: Arch+KDE
Posts: 16,552
Move a few of them to a new directory, then cd into that directory and run the mv command from there. This will tell us if a file in /home is causing the problem.
<edit>
PS: Also, post a few of the file names. Do any have spaces or other special characters?
Last edited by pixellany; 11-23-2009 at 02:15 PM .
11-23-2009, 02:18 PM
#8
Member
Registered: Nov 2007
Posts: 108
Original Poster
Rep:
ahhh. there it is.
One of the files was starting with a dash in its name.
specifically -ddfasdfa.txt thats why it was complaining.
After rename was able to move without issues.
thanks all
Quote:
Originally Posted by
AlucardZero
11-23-2009, 02:26 PM
#9
Guru
Registered: Nov 2005
Location: Pasadena, CA
Distribution: Arch+KDE
Posts: 16,552
Code:
[mherring@mystical stuff]$ echo "hello" > "-d words.txt"
[mherring@mystical stuff]$ ls
-d words.txt
[mherring@mystical stuff]$ mv *txt ..
mv: invalid option -- 'd'
Try `mv --help' for more information.
[mherring@mystical stuff]$
Just one example of a filename that mv will choke on. (as will many utilities)
11-23-2009, 02:27 PM
#10
Guru
Registered: Nov 2005
Location: Pasadena, CA
Distribution: Arch+KDE
Posts: 16,552
Sorry---I was typing and testing while you were posting.
Good to see a happy ending
11-23-2009, 04:54 PM
#11
Gentoo support team
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 3,852
Check the mv and cp man page, look for "--". It's designed specifically for this purpose, you don't need to rename files.
11-23-2009, 05:22 PM
#12
Guru
Registered: Nov 2005
Location: Pasadena, CA
Distribution: Arch+KDE
Posts: 16,552
Quote:
Originally Posted by
i92guboj
Check the mv and cp man page, look for "--". It's designed specifically for this purpose, you don't need to rename files.
This works, but it is not discussed on the man page.
I did find this (which I had seen before and forgotten):
http://www.gnu.org/software/coreutil...Common-options
11-23-2009, 05:38 PM
#13
Gentoo support team
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 3,852
It truly depends on the man page you look at. It is in mine. If you just search on the net you probably are going to hit some standard posix man page first, which will not include this extension. This is GNU extension, so it's more than probable that it's not present in any non-GNU OS.
Thread Tools
Search 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
HTML code is Off
All times are GMT -5. The time now is 07:18 AM .
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know .
Latest Threads
LQ News