I'm actually new to bash scripting. I'm trying to create a script that will read a text file containing a list of file "root" names (example: GBD_22, TBDDR_04, etc.). I need to find each file that has names that begin with these roots (example: GBD_22.R1.fastq.gz, GBD_22.R2.fastq.gz, GBD_22.read.gz, TBDDR_04.R1.fastq.gz, and so forth). The files scattered in a series of subfolders inside a main "source" directory. I need to find and copy the files from wherever they are to a main "output" directory also in the pwd. The text file, the source directory and the output directory are all at the same level in the pwd. So far I have started with the following script:
#!/bin/env bash
for file in $(cat ~/name.txt)
do cp "$file"* ~/OUTPUTDIR
done
The script reads the text file with the list of file "family" names, but fails to actually do the file find in the "deposit" directory, much less copy the files. Any help is very much appreciated. When I run the script, the result is:
cp: cannot stat 'CBD_22*': No such file or directory
cp: cannot stat 'CBD_23*': No such file or directory
cp: cannot stat 'TBDDR_04*': No such file or directory