I am trying to write a script that will copy all file listed in a text file (100s of file names) to a new directory each time I run it
Im trying to work up a test script using this model
Assume the script will run with main as current working directory and I know how many files/lines will be in List.txt
Contents of main
script.sh
sort < is a folder
List.txt
stuff.pdf
misc.rtf
junk.txt
thing.txt
Contents of List.txt
stuff.pdf
misc.rtf
thing.txt
Script so far (contests of script.sh)
#1/bin/bash
count =0
while [ $count -le 3 ]
do
filename= sed -n '1p' List
cp $filename sort
count=$(($count + 1 ))
done
Problems
(1)
count though lines with counter
something like
filename= sed -n '$countp' List
Im open to useing a different command here cat or whatever
but I want it to take the value from $count and grab whatevers is on the coresponding line in List.txt and store the result in a variable
(2)
use the file name stored in $filename in copy command
right now its viewing sort as the source not the destination $filename is not being read in
Any help would be appreciated![]()

Reply With Quote
