LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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


Reply
  Search this Thread
Old 10-03-2010, 01:45 PM   #1
a.albreiki
LQ Newbie
 
Registered: Apr 2008
Posts: 27

Rep: Reputation: 0
mv command with files name include spaces


Dear all

one system send files to linux machine and it is name contains spaces and i tried to move it from one directory to other,but it show error

ex:-

mv -f file one file two
mv: target `one' is not a directory

-------

that is all
 
Old 10-03-2010, 02:45 PM   #2
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
Use quotes:

First type:
Code:
mv 'Large File Na
press Tab and it should auto-complete it:

Code:
mv 'Large File Name'
then put the destination directory. You can use either single or double quotes, but single quote is safer so that bash wont interpret anything in the quotes.
 
Old 10-04-2010, 01:37 AM   #3
a.albreiki
LQ Newbie
 
Registered: Apr 2008
Posts: 27

Original Poster
Rep: Reputation: 0
Hi H_TeXMeX_H,

Thanks alot,

it is work in command shell.

but is not work in bash script please any advice

This is from my bash script and it is work with for loop and it is fine when i show the result with echo. but when applied mv command show that error

#--------------------------------------------------------------------
mkdir -p /nfs04/archive/${DIR}/${year}/${month}/${day}/
mv -f '{$FILE}' /nfs04/archive/${DIR}/${year}/${month}/${day}/.
sleep 5
#---------------------------------------------------------------------

THIS IS THE RESULT OF set -x
+ mkdir -p /nfs04/archive/A_BCD_EFG_Disk0/2010/10/03/
+ mv -f '{A-BCD-EFG-Disk 0-201010031330-4095.SSS}' /nfs04/archive/A_BCD_EFG_Disk0/2010/10/03/.
mv: cannot stat `{A-BCD-EFG-Disk 0-201010031330-4095.SSS}': No such file or directory
+ sleep 5
#-----------------------------------------------------------------------

Regards
 
Old 10-04-2010, 01:44 AM   #4
jdkaye
LQ Guru
 
Registered: Dec 2008
Location: Westgate-on-Sea, Kent, UK
Distribution: Debian Testing Amd64
Posts: 5,465

Rep: Reputation: Disabled
I think using backslash-space should work in a script. Suppose your file is called "my file". Then you could try
Code:
mv my\ file newfile
this should rename "my file" as "newfile". I've done this often on the command line but never tried it in a script.
ciao,
jdk
 
Old 10-04-2010, 02:43 AM   #5
a.albreiki
LQ Newbie
 
Registered: Apr 2008
Posts: 27

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by jdkaye View Post
I think using backslash-space should work in a script. Suppose your file is called "my file". Then you could try
Code:
mv my\ file newfile
this should rename "my file" as "newfile". I've done this often on the command line but never tried it in a script.
ciao,
jdk

Thank you,

but i use bash script and file name save in parameter

and the files has different name for that i can't add backslash-space for it.

Last edited by a.albreiki; 10-04-2010 at 02:55 AM.
 
Old 10-04-2010, 04:44 AM   #6
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
Try:

Code:
mkdir -p "/nfs04/archive/${DIR}/${year}/${month}/${day}/"
mv -f "{$FILE}" "/nfs04/archive/${DIR}/${year}/${month}/${day}/."
sleep 5
 
Old 10-05-2010, 04:46 AM   #7
a.albreiki
LQ Newbie
 
Registered: Apr 2008
Posts: 27

Original Poster
Rep: Reputation: 0
Smile

Quote:
Originally Posted by H_TeXMeX_H View Post
Try:

Code:
mkdir -p "/nfs04/archive/${DIR}/${year}/${month}/${day}/"
mv -f "{$FILE}" "/nfs04/archive/${DIR}/${year}/${month}/${day}/."
sleep 5


Thanks H_TeXMeX_H very much and it is work well.

Regards
 
  


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
Trying to Run Linux Command with Spaces! tfranklin Linux - Newbie 4 01-21-2010 07:45 PM
How to add some spaces in sed command? reconcil Linux - Newbie 2 11-05-2007 11:00 AM
Need Command to see free spaces shipon_97 Linux - Newbie 4 11-24-2006 08:50 AM
Use spaces in command line? Geminias Linux - Newbie 2 01-03-2006 07:37 PM
Spaces on command line odd Linux - Software 2 05-22-2004 08:17 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 09:21 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
Open Source Consulting | Domain Registration