Reputation: 1041
I have a folder which contains multiple files and one file (file_list
), which lists the files of interest. I want to create symbolic links to all files that match the file names in the list. Is there an easy way to do this in bash?
Example:
file1
, file2
, file3
, file4
, file5
file_list
: file1, file3, file5
file1
, file3
and file5
Upvotes: 0
Views: 2700
Reputation: 2428
Something like this should work as cp -s
makes symbolic links
cp -s $(cat file_list) /path/to/destination/dir/
Upvotes: 0
Reputation: 7499
Something like this should do:
#!/usr/bin/env bash
while IFS= read -r file; do
[[ -e /some/path/$file ]] && ln -s "/some/path/$file" /dest/path
done < file_list
Upvotes: 2