LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > AIX
User Name
Password
AIX This forum is for the discussion of IBM AIX.
eserver and other IBM related questions are also on topic.

Notices

Reply
 
LinkBack Search this Thread
Old 07-14-2008, 10:06 AM   #1
lqchangba
LQ Newbie
 
Registered: Feb 2007
Posts: 19

Rep: Reputation: 0
mv command not working


#mv /abc/* /xyz
0403-027 The parameter list is too long
this messages is given when i try to move or copy the cpntent of the directory but
#mv /abc/ /xyz/
this works
but i want to move the contents of /abc directory
 
Old 07-14-2008, 10:32 AM   #2
indienick
Senior Member
 
Registered: Dec 2005
Location: London, ON, Canada
Distribution: Arch, Ubuntu, Slackware, OpenBSD, FreeBSD
Posts: 1,853

Rep: Reputation: 65
If you want to move the contents, then you should go:
Code:
# mv /abc/* /xyz/
The first line you provided doesn't work, because not having a trailing slash ("/xyz" as opposed to "/xyz/") means you are trying to move all of the files in /abc and rename them to /xyz; keep in mind Linux and UNIX have never had a "rename" command - to rename things you "mv" them.

The second line should only give you the desired result if you provide a trailing asterisk "*" from the source - as I provided in my example - so you're moving all of the second-level ("/abc/*" = top level, "/abc/*" = second level) items into the destination directory. Your "mv" command is working.
 
Old 07-14-2008, 11:01 AM   #3
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 96
Quote:
Originally Posted by indienick View Post
If you want to move the contents, then you should go:
Code:
# mv /abc/* /xyz/
The first line you provided doesn't work, because not having a trailing slash ("/xyz" as opposed to "/xyz/") means you are trying to move all of the files in /abc and rename them to /xyz; keep in mind Linux and UNIX have never had a "rename" command - to rename things you "mv" them.

The second line should only give you the desired result if you provide a trailing asterisk "*" from the source - as I provided in my example - so you're moving all of the second-level ("/abc/*" = top level, "/abc/*" = second level) items into the destination directory. Your "mv" command is working.
Uhh, nonsense. Doing a 'mv /abc/* /xyz' is fine. The problem is the shell expansion is creating a command line that's too long for his shell (or maybe the mv command).

Try 'for go in /abc/*; do mv $go /xyz; done' assuming you're using ksh or another bourne type shell.

Dave
 
Old 07-14-2008, 11:09 AM   #4
pwc101
Senior Member
 
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,846

Rep: Reputation: 128Reputation: 128
Quote:
Originally Posted by ilikejam View Post
Try 'for go in /abc/*; do mv $go /xyz; done' assuming you're using ksh or another bourne type shell.
This may take ages given the machine has to spawn a new instance of mv for every file (and this will be a lot, given the original error message). find can do this in combination with xargs a lot more quickly, or indeed on its own:
Code:
find /abc -exec mv "{}" /xyz \+
find /abc -print0 | xargs -0 -I mv {} /xyz
Having the \+ at the end of the find command makes is save a number of input files in a queue, and then batch process them; the alternative (\;) spawns a new instance of rm for each file, which is probably no improvement over the for-loop method.

See http://en.wikipedia.org/wiki/Xargs for more examples.

Last edited by pwc101; 07-14-2008 at 11:11 AM. Reason: added link
 
Old 07-14-2008, 11:24 AM   #5
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 96
Quote:
Originally Posted by pwc101 View Post
This may take ages given the machine has to spawn a new instance of mv for every file (and this will be a lot, given the original error message). find can do this in combination with xargs a lot more quickly, or indeed on its own:
Code:
find /abc -exec mv "{}" /xyz \+
find /abc -print0 | xargs -0 -I mv {} /xyz
Having the \+ at the end of the find command makes is save a number of input files in a queue, and then batch process them; the alternative (\ spawns a new instance of rm for each file, which is probably no improvement over the for-loop method.

See http://en.wikipedia.org/wiki/Xargs for more examples.
Almost. 'find' finds the containing directory first, so you'll end up with /xyz/abc in the first operation, then a load of 'file not found's.

Might get away with a 'find -depth /abc -exec mv "{}" /xyz \+' though.

Dave
 
Old 07-14-2008, 11:36 AM   #6
pwc101
Senior Member
 
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,846

Rep: Reputation: 128Reputation: 128
Quote:
Originally Posted by ilikejam View Post
Almost. 'find' finds the containing directory first, so you'll end up with /xyz/abc in the first operation, then a load of 'file not found's.

Might get away with a 'find -depth /abc -exec mv "{}" /xyz \+' though.

Dave
Ah, yes, I hadn't thought of that.

Every day's a school day
 
Old 07-23-2008, 05:13 PM   #7
opeyrega
LQ Newbie
 
Registered: Feb 2006
Location: Machecoul Fr
Distribution: fedora
Posts: 17

Rep: Reputation: 0
the problem is the parameter nargs on your box
with your command you take all args after your mv.
I think you have many files in this directory

try this command lsattr -El sys0 and view nagrs's parameters
You must increase this value
 
Old 07-23-2008, 05:31 PM   #8
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 59
Another trick is to notice that will often work:

mv /abc/* /xyz

actually turns into

mv /abc/x /abc/y /abc/z ...

Notice that the string "/abc/" is used over and over again. By cd'ing into the directory, you can reduce the arg length because * will then expand into only the contents of the directory:

cd /abc
mv * /xyz

This won't work of course if the expansion of * still exceeds the limit. Then find is easiest.
 
Old 07-23-2008, 08:52 PM   #9
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,695
Blog Entries: 5

Rep: Reputation: 239Reputation: 239Reputation: 239
you can use xargs along with mv.
 
Old 07-23-2008, 09:31 PM   #10
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 59
Quote:
Originally Posted by ghostdog74 View Post
you can use xargs along with mv.
Alas, unfortunately, not with BSD mv, which lacks the ability to specify the target directory via -t. That is a nice, missing feature.
 
  


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
mail command not working soroccoheaven Linux - Server 3 10-07-2010 05:38 AM
du -sh * Command not working young_rhkid Linux - Newbie 3 10-01-2007 11:51 AM
at command not working??? sulekha Ubuntu 2 07-27-2007 01:17 PM
su command not working dahmad Linux - Newbie 6 02-28-2003 12:08 AM
ps command not working slackerboy Slackware 2 08-22-2002 11:01 PM


All times are GMT -5. The time now is 10:38 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration