Recursively move directories along with files/specific files
I would like to transfer all files ending with .log from /tmp and to /tmp/archive (using find )
The directory structure looks like :-
When I tried the following command , it movies all the log files to /tmp/archive (does not maintain the directory structure ) The output is
whereas the output should be
For copying (cp) ,this can be done using -R but does not work with move (mv) .Is there any simple command to achieve this .
I had gone through forums and come across few commands rsync ,tar ......
Also , could anyone explain the difference between cp and rsync
What is the usage of the command tar?
Last edited by Franklin52; 05-24-2011 at 01:52 PM..
Reason: Please use code tags
Bartus ,
I did understand the first part of the command
Could you also please explain the later part of the command ,
xargs -i bash -c "echo {} | cpio -pdmu /tmp/arc; rm -f {}" What is the usage of xargs , bash , cpio -pdmu
First tell us if it worked in your case . xargs is passing the output from find as "{}". It is then used in bash command to execute two utilities: cpio and rm. cpio copies the file with its subdirectories if necessary (-d cpio option), while rm removes the original file after it has been copied.
What Operating System and version do you have?
What Shell do you use?
On a design point, is this a one-off exercise or a job which will be run more than once? There are real scripting issues with your archive directory /tmp/archive being under /tmp .
Also on most unix systems /tmp is of limited size and considered volatile storage for files used by the Operating System. It is usual to create separate filesystems for application data and logs.
$ ls -R /usr/bin/abcd
/usr/bin/abcd:
efgh fff1.log fff2.log fff3.log
/usr/bin/abcd/efgh:
fff4.log fff5.log
/* I am creating another directory called abcd1*/
$ mkdir /usr/bin/abcd1
/* Using your command , I am moving the *.log files from abcd to abcd1 ,including the directory structure ( sub directories ). As you can see , it fails with the output below */
Hello,
I'm a first time poster looking for help in scripting a task in my daily routine. I am new in unix but i am attracted to its use as a mac user.
Bear with me...
I have several files (20) that I manually drag via the mouse into several named directories over a network. I've used rsync... (14 Replies)
Is it possible to only copy selected files+its directories when you are copying recursively?
find /OriginalFolder/* -type -d \{ -mtime 1 -o -mtime 2 \ } -exec cp -R {} /CopyTo/'hostname'__CopyTo/ \; -print
From the above line, I want to only copy *txt and *ini files from /OriginalFolder/*
... (4 Replies)
Hi.
I found many scripts in the web of achieving this.
But I like to use this one
find /EDWH-DMT03 -xdev -size +10000 -exec ls -la {} \;|sort -n -k 5 > LARGE.rst
But the problem is, why it still list out files with 89 bytes as the output? Is there anything wrong with the command?
My... (7 Replies)
Hi,
In a parent directory there are several files in the form
IDENTIFIER1x
IDENTIFIER1.yyy
IDENTIFIER1_Z, etc
IDENTIFIER2x
IDENTIFIER2.yyy
IDENTIFIER2_Z, etc
IDENTIFIER3x
IDENTIFIER3.yyy,
IDENTIFIER3_Z, etcIn the same parent directory there are corresponding directories named... (7 Replies)
Hi,
Seems like I need help again with a problem:
I want to delete all files from my lets say "Music" Directory inkluding all of the subfolders
except for .mp3 and .MP3 files.
I tried it with globalignoring mp3 files, finding and deleting all other files, which
resulted in all files... (3 Replies)
Hi,
Please help me, how to get all the direcotries, its sub directories and its sub directories recursively, need to exclude all the files in the process.
I wanted to disply using a unix command all the directories recursively excluding files.
I tried 'ls -FR' but that display files as... (3 Replies)
Hi,
I have various log files in different paths. e.g.
a/b/c/d/e/server.log
a/b/c/d/f/server.log
a/b/c/d/g/server.log
a/b/c/h/e/server.log
a/b/c/h/f/server.log
a/b/c/h/g/server.log
a/b/c/i/e/server.log
a/b/c/i/e/server.log
a/b/c/i/e/server.log
and above these have an archive folder... (6 Replies)
Hello, this is probably another really simple tasks for most of you gurus, however I am trying to make a script which takes an input, greps a specific file for that input, prints back to screen the results (which are directory names) and then be able to use the directory names to move files.... (1 Reply)
Hi
I am a shell-script newbie and am looking to synchronize certain files in two directory structures.
Both these directory-trees are in CVS and so I dont want the CVS directory to be copied over.
I want only .sh and .pl files in each subdirectory under these directory trees to be... (3 Replies)