How to copy files/folders and show the files/folders?
Hi,
So i know we use cp -r as a basic to copy folders/files.
I would like this BUT i would like to show the output of the files being copied.
With the amazing knowledge i have i have gone as far as this:
1)
2)
I am just not successful, the command is successful but the target folder is showing files, from the source folder's sub folders, in its root folder.
If you do a test you will see what i mean.
So basically i have a folder called source and another called target.
I just want to copy the contents of the source folder to the target folder, that's it. No need to create the source folder+content within the target folder
Just the content of source in to target.
This is very simple and yet i can not accomplish this.
I know you can use rsynch , should i be ?
any unix admin would say , nah cp -rp is fine.... ?
what about cpio ? maybe find . and then passing that to cpio.
I dont know.
Anyways, i have tried what i have and not managing.
Any recommendations please.
Last edited by vbe; 10-18-2016 at 03:46 PM..
Reason: please use code tags
I had a hard day so not sure what you mean... as using cp -r to copy directories , I dont because of issues with links files perms etc... and prefer using cpio or tar on the fly, now as I ma leving work I wont test what you mean to see but I will not stop you testing with cpio... e.g.
And say what you think of it
Will be home soon ( I hope...)
I shall give that command a try and see if it looks good, thanks.
I will also come back to you.
---------- Post updated 10-19-16 at 11:17 AM ---------- Previous update was 10-18-16 at 11:07 PM ----------
Quote:
Originally Posted by vbe
I had a hard day so not sure what you mean... as using cp -r to copy directories , I dont because of issues with links files perms etc... and prefer using cpio or tar on the fly, now as I ma leving work I wont test what you mean to see but I will not stop you testing with cpio... e.g.
And say what you think of it
Will be home soon ( I hope...)
There is a slash before the <destdir> that you mention, i am kind of worried?
Do i need that slash?
Or do i just type my "destdir" and tab which will auto complete as "destdir/"
There is a slash before the <destdir> that you mention, i am kind of worried?Do i need that slash?
Or do i just type my "destdir" and tab which will auto complete as "destdir/"
Hello Imre,
you need to provide path there, I would prefer absolute path in there, for an example /tmp/abc/test/my_test. So if you give /abc/test/my_testbecause it is a directory not a mount point it will not work though if you give like abc/test/my_test should work. Please try it out into a test environment or a test directory first and once it is giving expected results then you could run it into the actual environment.
Thanks,
R. Singh
Last edited by RavinderSingh13; 10-19-2016 at 07:43 AM..
Hello MR Singh,
So i have urn that command it does exactly the same as my amazing for loop tests and cp -rp and other stuff, what a pain.
Basically they work.
I am so annoyed that i dont understand basics or dont know proper practices , i just want to do stuff the correct way. Maybe i know them and im just undermining myself i dont know.
I want to copy the files in the folder to the target folder, NOT the base folder.
so i want to copy literally a folder called "source" to "target" BUT only the content of the source folder and NOT the folder called source also.
I have tried to use
flip i am struggling.
that cut should work but cpio is failing because it is trying to copy text and it doesnt know that it is actually objects to copy.
Moderator's Comments:
Please use CODE tags as required by forum rules!
Last edited by RudiC; 10-19-2016 at 08:39 AM..
Reason: Added CODE tags.
Referring to vbe's post#2 and suggested command line he gives (which is the way to do it), I would comment as follows.
1. The destination path MUST already exist before the command is run. If necessary create the destination path yourself first.
2. If you are copying within a filesystem then don't use the 'l' switch on the cpio command otherwise it will link the files where possible and won't actually copy them (although of course the files will appear in the new path location because of the links made).
3. Before you run the command execute a 'cd' command to the source location of the files to be copied. If you use a '.' in the find command then everything in that directory will be copied. If you only want a subset then you need to specify that subset within find. Once you have 'cd' to the source location a mirror image of the files you can see with a 'ls' command will be copied to the destination folder. An exact copy of the whole tree, sub-directories and all.
4. If you want to see more information as the files are copied include a 'v' switch in cpio (eg, cpio -puvdm /<dest dir>)
If you're still having trouble making this work do post back your problem. We can sort it.
---------- Post updated at 05:34 PM ---------- Previous update was at 12:45 PM ----------
My way forward to complete this is indeed to actually go in to the Source folder (which does exist) and then do a loop listing the objects in that folder.... and cp and echo what i am coying... the Source Target directory does exist....
I will have to put in return code checks to make sure the change directory works, and then i can put one in for the copy as well.
Dear All,
I will appreciate any help received. Our system is running on hpux v1
My problem is as follows:
We have many customer folders with name fd000100, fd000101 and so on
e.g.
(Testrun)(testsqa):/>ll /TESTrun/fd000100
total 48
drwxrwx--- 2 fq000100 test 96 Jun 27 2004... (17 Replies)
Hi,
I need help in shell scripting. If someone can help me, that would be great!
Problem. I want Linux Script to compare two folders and copy missing files.
Description.
I have two directories
/dir1
/dir2
I need to copy all distinct/new/unique/missing files from /dir1 and that... (1 Reply)
Hello again,
A little while back I got help with creating a command to search all directories and sub directories for files from daystart of day x.
I'm wondering if there is a command that I've overlooked that may be able to search for / write folder names to an output file which ideally... (2 Replies)
Folks,
I am hopeful that you may be able to help me out with writing a script that can be run nightly (as cron?) to loop through all subfolders within the "/media" directory, delete all of the files in each of them, and then copy in all of the files from the "/home//sansa" directory to each of... (6 Replies)
Hi,
I just started to learn shell progamming and just can't get my head around the following problem.
I need to do the following:
I have a folder which contains 100+ subfolders. Inside these subfolders there is one folder named 'Morph' and several jpg's.
I need to copy all the files into... (4 Replies)
I have files existing with same names in the folders with date as display below
c:\2010-09-10 <==== folder
arr1.jpg
arr2.jpg
arr3.jpg
arr4.jpg
c:\2010-09-09 <==== folder
arr1.jpg
arr2.jpg
c:\2010-09-08 <==== folder
arr2.jpg
arr3.jpg
arr4.jpg
... (5 Replies)
Hi..
I have 2 servers with linux suse10.
I made a mistake and on one of the servers changed with chmod the permission of root in directory /.
In the other servers the permissions are correct
Please i need a script, to change the permissions of one server 1, using the same permission of the... (11 Replies)
i have users home directories in /home
all the users have some files starting with character e
and i want to copy all these files in a folder in my (root) home
using a script
i tried the script
for i in m5
do
cd m5
cp e1* /home/pc/exam
cd ..
done
but get these... (3 Replies)
Hi everyone,
I'm stuck with this scenario where our system creates files every night and puts them in several folders according from whom it came from.
I have managed to create a script which will list the folders in one column and the files that are in them in another column, now my problem... (6 Replies)
So tried:
cp -r -p test1/ user@machine:///srv/www/vhosts/domain.co.uk/httpdocs/backup/
but this didn't work either :(
Anyone able to help with this?
Many thanks
Mr M (3 Replies)