file1.txt contains:
mann
mcdevitt
kirkland
file2.txt contains:
mannt
mcdevittd
kirklandv
i want to copy /mann/* /mannt
cat /tmp/file1.txt | while read file1
do
cat /tmp/file2.txt | while read file2
do
cp -rp /tmp/$file1/* /tmp/$file2
done
done
when i du -sm /tmp/mannt , it's bigger than /tmp/mann
it should be identical.
bash-3.2$ cat 1.txt
bc
bn
nv
bash-3.2$ cat 2.txt
dbc
gnv
kjds
bash-3.2$ paste 1.txt 2.txt |xargs -n2 echo cp
cp bc dbc
cp bn gnv
cp nv kjds
bash-3.2$ paste 1.txt 2.txt |xargs -n2 echo cp |sh
@OP: Your script is copying all files in all directories in file1 to every directory in file2
To read two file in the same loop, it get slightly more complicated:
while read file1 && read file2 <&3
do
cp -rp /tmp/"$file1"/* /tmp/"$file2"
done <file1.txt 3<file2.txt
Scrutinizer,
thank you much. worked perfectly.
what does <$3 mean ?
<file1.txt 3<file2.txt - read from file1 and file2
3<file2.txt ties up to <$3 ?
<&3 means read from what ever file descriptor 3 is directed to. Indeed, at the bottom of the loop it is defined to read from file2.txt
thank you much, that's what i thought. again, thanks.
ctsgnb
7
use the thanks button then :rolleyes:
It seems like a shell way to get 'paste'.