LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-13-2007, 04:33 AM   #1
George2
Member
 
Registered: Oct 2003
Posts: 354

Rep: Reputation: 30
mv file name contains space character


Hello everyone,


I have a file name "foo goo.tar" on Linux and I want to rename it to newname. I am using the following command, but it fails. How to solve it,

mv foo\ goo.tar newname
mv.orig: when moving multiple files, last argument must be a directory
Try `mv.orig --help' for more information.


thanks in advance,
George
 
Old 11-13-2007, 04:38 AM   #2
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670
Are you using the bash shell?

This works, so I think you may have made a typo.
Code:
touch 'foo goo.tar'
mv foo\ goo.tar foo_goo.tar
 
Old 11-13-2007, 04:53 AM   #3
George2
Member
 
Registered: Oct 2003
Posts: 354

Original Poster
Rep: Reputation: 30
Thanks jschiwal,


Quote:
Originally Posted by jschiwal View Post
Are you using the bash shell?

This works, so I think you may have made a typo.
Code:
touch 'foo goo.tar'
mv foo\ goo.tar foo_goo.tar
Still not working, this is the output.

touch foo\ goo.tar
(no output)
mv foo\ goo.tar foo_goo.tar
mv.orig: when moving multiple files, last argument must be a directory
Try `mv.orig --help' for more information.

Any more ideas? How to check which shell is using?


regards,
George
 
Old 11-13-2007, 04:59 AM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
To retrieve the current shell you can
Code:
echo $SHELL
also, can you try the following?
Code:
alias mv
mv.orig --help
I am puzzled about what is mv.orig.
 
Old 11-13-2007, 05:02 AM   #5
George2
Member
 
Registered: Oct 2003
Posts: 354

Original Poster
Rep: Reputation: 30
Thanks colucix,


Quote:
Originally Posted by colucix View Post
To retrieve the current shell you can
Code:
echo $SHELL
also, can you try the following?
Code:
alias mv
mv.orig --help
I am puzzled about what is mv.orig.
Here is the output of echo $SHELL

echo $SHELL
/bin/bash

Here is the output of alias mv

alias mv
-bash: alias: mv: not found

Here is the output of mv.orig --help

mv.orig --help
Usage: mv.orig [OPTION]... SOURCE DEST
or: mv.orig [OPTION]... SOURCE... DIRECTORY
or: mv.orig [OPTION]... --target-directory=DIRECTORY SOURCE...
Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.

Mandatory arguments to long options are mandatory for short options too.
--backup[=CONTROL] make a backup of each existing destination file
-b like --backup but does not accept an argument
-f, --force do not prompt before overwriting
(equivalent to --reply=yes)
-i, --interactive prompt before overwrite
(equivalent to --reply=query)
--reply={yes,no,query} specify how to handle the prompt about an
existing destination file
--strip-trailing-slashes remove any trailing slashes from each SOURCE
argument
-S, --suffix=SUFFIX override the usual backup suffix
--target-directory=DIRECTORY move all SOURCE arguments into DIRECTORY
-u, --update move only when the SOURCE file is newer
than the destination file or when the
destination file is missing
-v, --verbose explain what is being done
--help display this help and exit
--version output version information and exit

The backup suffix is `~', unless set with --suffix or SIMPLE_BACKUP_SUFFIX.
The version control method may be selected via the --backup option or through
the VERSION_CONTROL environment variable. Here are the values:

none, off never make backups (even if --backup is given)
numbered, t make numbered backups
existing, nil numbered if numbered backups exist, simple otherwise
simple, never always make simple backups

Report bugs to <bug-coreutils@gnu.org>.

Any more ideas?


regards,
George
 
Old 11-13-2007, 05:32 AM   #6
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
The output of mv.orig --help is exactly the same of the mv command from coreutils and since the mv command is not aliased, I suspect you have a link in /bin as
Code:
mv --> ./mv.orig
anyway, this cannot be the problem unless mv.orig is a modified version of the mv command. You can try to investigate about this issue. In the meanwhile if you have the rename command, you can try something like
Code:
rename "foo " "foo_" "foo goo.tar"
See man 1 rename for details.
 
Old 11-13-2007, 06:09 AM   #7
George2
Member
 
Registered: Oct 2003
Posts: 354

Original Poster
Rep: Reputation: 30
Thanks colucix,


Quote:
Originally Posted by colucix View Post
The output of mv.orig --help is exactly the same of the mv command from coreutils and since the mv command is not aliased, I suspect you have a link in /bin as
Code:
mv --> ./mv.orig
anyway, this cannot be the problem unless mv.orig is a modified version of the mv command. You can try to investigate about this issue. In the meanwhile if you have the rename command, you can try something like
Code:
rename "foo " "foo_" "foo goo.tar"
See man 1 rename for details.
The rename command works! Cool!

I am interested to investigate what is wrong with mv command on my machine. Could you describe more deailed steps please?

How to check whether mv is the same as mv.orig?


regards,
George
 
Old 11-13-2007, 07:13 AM   #8
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670
I never heard of "mv.orig". What does "type mv.orig" say? Is it a command or an alias or a function?

It could be a function that calls mv but doesn't handle the arguments properly causing the argument to be passed to mv as two arguments. You could call mv like "/bin/mv foo\ goo.tar foo_goo.tar".
 
Old 11-13-2007, 07:44 AM   #9
nx5000
Senior Member
 
Registered: Sep 2005
Location: Out
Posts: 3,307

Rep: Reputation: 55
Maybe try this:
Code:
type mv
 
Old 11-13-2007, 02:39 PM   #10
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
I suggest also to do a simple
Code:
ls -l /bin/mv*
We already discovered that it is not an alias, but the suggestion from jschiwal sounds right: it can be a function that does not handle arguments in the proper way.

Last edited by colucix; 11-13-2007 at 02:41 PM.
 
Old 11-13-2007, 10:50 PM   #11
George2
Member
 
Registered: Oct 2003
Posts: 354

Original Poster
Rep: Reputation: 30
Hi nx5000,


Quote:
Originally Posted by nx5000 View Post
Maybe try this:
Code:
type mv
Here is the output, any more ideas to find the root cause why mv is not working? Thanks.

type mv
mv is /bin/mv


regards,
George
 
Old 11-13-2007, 10:52 PM   #12
George2
Member
 
Registered: Oct 2003
Posts: 354

Original Poster
Rep: Reputation: 30
Hi colucix,


Quote:
Originally Posted by colucix View Post
I suggest also to do a simple
Code:
ls -l /bin/mv*
We already discovered that it is not an alias, but the suggestion from jschiwal sounds right: it can be a function that does not handle arguments in the proper way.
Here is the output of ls -l /bin/mv*

ls /bin/mv*
/bin/mv /bin/mv.2 /bin/mv.orig

It is appreciated if you could give us more ideas to find the root cause why mv is not working with file names containing space character.


regards,
George
 
Old 11-13-2007, 10:53 PM   #13
George2
Member
 
Registered: Oct 2003
Posts: 354

Original Poster
Rep: Reputation: 30
Thanks jschiwal,


I am following your comments,

Quote:
Originally Posted by jschiwal View Post
I never heard of "mv.orig". What does "type mv.orig" say? Is it a command or an alias or a function?

It could be a function that calls mv but doesn't handle the arguments properly causing the argument to be passed to mv as two arguments. You could call mv like "/bin/mv foo\ goo.tar foo_goo.tar".
type mv.orig
mv.orig is /bin/mv.orig

Any more ideas to find the root cause why mv is not working on my machine with file names containing space character?


regards,
George
 
Old 11-13-2007, 11:44 PM   #14
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670
Also try: "file /bin/mv /bin/mv.orig"

Where does the mv.orig come from? I have never heard of it and from the looks of things it doesn't work.

If you have a /bin/mv command, is it a link to /bin/mv.orig?

I wonder if .orig stands for "original". It seems that something modified "/bin/mv" and saved "/bin/mv.org" as a backup. Find which distro are you using? Find out where these files came from and if they are valid.
I'm hoping that a hacker didn't recompile your "mv" command. I might just be blowing smoke but something just doesn't smell right.

If you are using an rpm based system you can run "rpm -qV coreutils" to validate the file. I don't know how you would validate a debian package. What is your system by the way? You should put it in your LQ Profile so that we don't have to ask if it isn't mentioned.

It may be better to validate against your CDROM/DVD installation package:
rpm -qVp /path/to/coreutils-6.9-43.x86_64.rpm
However, if you have had a security update for coreutils, it may flag some false positives.
 
Old 11-14-2007, 02:50 AM   #15
George2
Member
 
Registered: Oct 2003
Posts: 354

Original Poster
Rep: Reputation: 30
Thanks jschiwal,


I have followed your comments, here is output of file command

file /bin/mv /bin/mv.orig
/bin/mv: ASCII text
/bin/mv.orig: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.2.5, dynamically linked (uses shared libs), stripped

Here is the output of rpm -qV coreutils,

rpm -qV coreutils
S.5....T /bin/chgrp
S.5....T /bin/chmod
S.5....T /bin/chown
S.5....T /bin/mv
S.5....T /bin/rm


Let me know if you need more information to determine the root cause. I am interested to learn from you how to determine such strange issue. :-)


regards,
George

Quote:
Originally Posted by jschiwal View Post
Also try: "file /bin/mv /bin/mv.orig"

Where does the mv.orig come from? I have never heard of it and from the looks of things it doesn't work.

If you have a /bin/mv command, is it a link to /bin/mv.orig?

I wonder if .orig stands for "original". It seems that something modified "/bin/mv" and saved "/bin/mv.org" as a backup. Find which distro are you using? Find out where these files came from and if they are valid.
I'm hoping that a hacker didn't recompile your "mv" command. I might just be blowing smoke but something just doesn't smell right.

If you are using an rpm based system you can run "rpm -qV coreutils" to validate the file. I don't know how you would validate a debian package. What is your system by the way? You should put it in your LQ Profile so that we don't have to ask if it isn't mentioned.

It may be better to validate against your CDROM/DVD installation package:
rpm -qVp /path/to/coreutils-6.9-43.x86_64.rpm
However, if you have had a security update for coreutils, it may flag some false positives.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
what is the Linux command line character for a blank space? Peter Shepard Red Hat 3 06-21-2006 07:25 PM
incorrect character for the log file treotan Red Hat 1 12-05-2005 10:21 PM
windows space character equivalent powereds Linux - Networking 3 07-06-2005 06:06 AM
Check to see if a file has a certain character in it krock923 Programming 2 11-25-2004 04:30 PM
end of file character hyperriven Programming 2 04-08-2004 12:09 AM


All times are GMT -5. The time now is 01:24 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration