Looking for a find and copy command
I need a command to find and copy the files listed in test.txt (check the picture) to /destination/folder/
I have been using Code:
for i in `cat test.txt`;do cp "$i" /destination/folder/; done http://tinypic.com/r/vn2mub/5 Thanks |
Try
Code:
for i in `cat test.txt`;do cp `find . -name $i` /destination/folder/; done returns pathinwhichfileis/filename. |
HI Key67,Welcome to LQ.
Prefer Code:
$() Code:
`` Code:
while read file;do $(find . -name $file -exec cp {} /<destdir> \;);done < test.txt |
Code:
$ while read file;do $(find . -name $file -exec cp {} /home/4/ \;);done < test.txt cp: `./4/1a1.txt' and `/home/4/1a1.txt' are the same file then stopped Code:
for i in `cat test.txt`;do cp `find . -name $i` /destination/folder/; done cp: missing destination file operand after `/home/4/' |
Quote:
|
find command is recursive so if you are copying something from one of subfolders of lets say home folder (E.g. /home/you/Documents) and want to copy to some other subfolder in the same main folder (E.g. /home/you/Public) you will get that error because after finishing checking in /home/you/Documents it will search in /home/you/Public, tries to copy to itself. But it should not stop copying other files?!
Try: Code:
for i in $(cat test.txt); do find </main/folder> -iname $i -exec mv '{}' /destination/folder \; ; done |
thanks divyashree, adding the -f worked
Code:
while read file;do $(find . -name $file -exec cp -f {} /home/4/ \;);done < test.txt |
Quote:
|
All times are GMT -5. The time now is 03:38 PM. |