Computing.Net > Forums > Unix > How to move files from one dir to a

How to move files from one dir to a

Reply to Message Icon

Original Message
Name: nkbeet (by nk.mtnl)
Date: June 17, 2008 at 08:54:29 Pacific
Subject: How to move files from one dir to a
OS: UNIX
CPU/Ram: SERVER
Model/Manufacturer: IBM
Comment:

Dear Friends,
I have a directory named tech, there are many files with *.uni extensions in this directory.The files with *.uni are continuously coming in tech directory.In tech directory, there is one directory named best. Now i want to move the files with *.uni extensions in this best directory. How can i do that. Please suggest a script in UNIX for this.

NAVIN KUMAR


Report Offensive Message For Removal


Response Number 1
Name: nails
Date: June 17, 2008 at 09:54:19 Pacific
Reply: (edit)

The typical way of moving files and directories is with the mv command:

cd /pathto/tech
mv *.uni best

The above contains no error checking, so use the cp command until you get the script the way you want it.

Check out this link for more info on this topic:

http://students.cs.unipi.gr/pub/doc...


Report Offensive Follow Up For Removal

Response Number 2
Name: nkbeet (by nk.mtnl)
Date: June 18, 2008 at 00:12:39 Pacific
Reply: (edit)

Error "arguments too long" comes.

NAVIN KUMAR


Report Offensive Follow Up For Removal

Response Number 3
Name: nails
Date: June 18, 2008 at 09:06:19 Pacific
Reply: (edit)

You must be trying to move a very large number of files to get a "arguments too long" error. Generally, you can get around the "arguments too long" problem by using a combination of the find/xargs command.


Read about it in this online article, "Using the xargs Command":
http://www.unixreview.com/documents...

You can probably do something like this:

# untested untested untested
cd /pathto/tech
find ./ -type f -name "*.uni" -print | xargs -l56 -i mv -f {} ./best

I suggest you read the article.

I see another potential problem with having directory "best" right below the current directory. The find command probably will probably find those "uni" files.


Report Offensive Follow Up For Removal

Response Number 4
Name: nkbeet (by nk.mtnl)
Date: June 23, 2008 at 00:15:35 Pacific
Reply: (edit)

This also not worked.

nkbeet


Report Offensive Follow Up For Removal

Response Number 5
Name: nails
Date: June 23, 2008 at 11:36:04 Pacific
Reply: (edit)

You'd get more help if you posted WHY it didn't work. Also, asking the same question in a different thread won't do you much good either.


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: How to move files from one dir to a

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




Have you ever used OpenOffice?

Yes, as my main suite.
Yes, occationally.
Yes, but only once.
No, never.


View Results

Poll Finishes In 4 Days.
Discuss in The Lounge