I'm trying to create symlinks to all files in a list of file names, where the file names in the list only partially match the names of the files.
I have a list of partial file names (file_name_list.txt)
cat file_name_list.txt
>file_ABC
>file_DEF
>file_GHI
the files I want to link are in a folder that looks like this:
ls -l <path to original files>
>new_file_ABC.txt
>file_ABC.fasta
>OCTOBER_file_DEF.fa
>file_DEF.gff
>file_GHI.txt
>file_XYZ.txt
where the intended result would be :
ls -l <path to symlinked files>
new_file_ABC.txt
file_ABC.fasta
OCTOBER_file_DEF.fa
file_DEF.gff
file_GHI.txt
what I've tried:
while IFS= read -r file; do
[[ -e <path to files>/*"$file"* ]] && ln -s <path to files>/*"$file"* .
done < file_name_list.txt ```