Is there a copy command that allows piping from a text file? Something like…
cat filelist.txt | copycommand --recursive destination_directory
Thanks.
Is there a copy command that allows piping from a text file? Something like…
cat filelist.txt | copycommand --recursive destination_directory
Thanks.
Might want to explain what you actually want to do because I struggle to comprehend that. It sounds like you want to cat a file then copy recursively which makes no sense. Just copy recursively.
I suspect what your trying to achieve is more than possible and probably wants redirection over a pipe, but as said can’t give an exact as I’m really unsure what you’re actually trying to achieve. It maybe that tee is better for the job.
I want to prepare a list of files and or directories in a file called filelist.txt to be copied to a specific existing directory to be named on the command line. “cat filelist.txt |” would pipe these as parameters to a copy utility. The filenames might exist in different directories or filesystems and will have no discernable patterns.
Thanks for your help.
rsync may be the easiest otherwise I suspect a rather convoluted function using a read could be done.
rsync --files-from= which will take the file or - to use stdin. Check the man page for the exact syntax.
for i in $(cat filelist.txt); do
cp -f "$i" "/new/path/$i"
done
Something like this?
Thank you very much people. The second solution looks quite elegant, but I will try both.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
SYNOPSIS
cp [OPTION]… -T] SOURCE DEST
cp [OPTION]… SOURCE… DIRECTORY
cp [OPTION]… -t DIRECTORY SOURCE…
So…
cp -t /path/to/destination cat filelist.txt | xargs
I have not tested this yet, but it looks good to me.
Good luck.
ionmich wrote:
> Thank you very much people. The second solution looks quite elegant, but
> I will try both.
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iQIcBAEBAgAGBQJKchkpAAoJEF+XTK08PnB5lbAQAMYxQNzPr9KAQ9NN6bsc60z4
m9A0H0Fe5kKt+plmc6bqjLdF/jz3DElXnWmP/7yG3IGKI8uar5FSIZWURRuE4UwZ
uAZnUGdeB4eJ1ly0j9aZhYnysNrmLgVIN9igTe03evJghQe29JWTrM5h4I3AqR5m
3Y3KzFDf6eZlx4hgCE9lNIy/Iuk5OPqzuVnTXm56Qix+G83Tlp9KXM2lKmilPU6U
O3/f+Fr6dNuj/tPCVRZ18FNVvzpzRx3RZHpkm6Ll3z2Z1tZL/P/BnQGpUaQq4jeX
Sm7AGVKeTzzbrYHzDT4bVeZjXk2QWRMVB/t4WczGJfGVPFq29p5OxIOyTe/OC9qv
a+a99HWj0v+1l49KzsqOXiv8bKHhGvExwTcsGfNApi8xopxXoO+Jhvbg9q4Qs8GL
0PGMevVL+QIW1smxR2a9Li4q+RfH6NowAn1olY/mnTO4iH/JY7cRKKZ0Y0qPvXLx
a3mmvxsx0gZ2NFS0bwJ2uy3XhFxlFunP0eVWlY4OO8Y16IHVu65atknWsZfT2WmW
9sZdqOJNeSBsQk4I/MQtfUMOGSZo9/Y+xZ7FeBAEvY2pyRXJf8/3muGVCoRMzYbc
R/Dyeq3TpKbtcxe2je1LCD8vFICD2ypotWO9GP/icRYqaKPSNFQ+RaTCmSzoli/r
/plGAKsAyQfvz8nfAZG+
=VTM1
-----END PGP SIGNATURE-----