LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Is there any command to check the each and every file copied recursively or not? (https://www.linuxquestions.org/questions/linux-newbie-8/is-there-any-command-to-check-the-each-and-every-file-copied-recursively-or-not-641794/)

nagendrar 05-13-2008 12:06 AM

Is there any command to check the each and every file copied recursively or not?
 
good moring!
pls give the suggetions for me.

I am copying the files recursively from one dir to another dir.

Here I am trying as below:
But here we get the each file recursively using find command.
If this file copied in installation path ,i am getting two files as

ex :
fname1=aaa/bbb/a.txt
installPath=/home/all/
then I am getting /home/all/aaa/bbb/a.txt , /home/all/a.txt

for fname in $folders
do
if [ -d "./$fname" ]
then
files=`find "$fname"`
for fname1 in $files
do
cp -r --preserve=mode $fname1 "${installPath}"/.
if [ $? -eq 0 ]
then
echo "Copied the file: "${installPath}""${fname1}"" >> "${installPath}"/SRMsetuplog.log
else
echo "Could not copy the file:"${installPath}""${fname1}"" >> "${installPath}"/SRMsetuplog.log
fi
done
fi
done


Is there any command to check the each and every file copied or not?

Pls give the suggetions for me

Thanq,
Nagendra

Bruce Hill 05-13-2008 12:31 AM

Use rsync rather than copy ... "man rsync" for complete information.

chrism01 05-13-2008 06:39 PM

This line

if [ -d "./$fname" ]

does not make sense.

./$fname means run this prog in the current dir

-d means is this a dir

Try

if [[ -d $fname ]]

Also,
installPath=/home/all/

ends with a slash, so

"${installPath}"/.

should be

"${installPath}"

and in fact drop the double quotes unless you have spaces in the filenames/dirnames (don't do that though...)




also, please provide the whole prog in code tags so the indentation shows up as well.


All times are GMT -5. The time now is 06:56 PM.