Reputation: 69
I'm trying to figure out a script file that takes in a file containing list of files and then copy only these files to a different directory. Any help would be appreiated.
Upvotes: 1
Views: 18355
Reputation: 171
I can't comment, therefore expanding slightly on fedorqui's answer, this adds quoting to handle filenames with spaces:
#!/bin/bash
destination="./output_files"
while read file
do
echo $file
cp "$file" $destination
done < input_files
Upvotes: 0
Reputation: 62519
cpio -pmu /new/directory < file
Assuming you have cpio
installed, anyway...
Upvotes: 2
Reputation: 26
file="/work/file.txt"
for j in `cat $file`
do
cp ${j} /destination/direc
done
Upvotes: 0