我有一个文件夹,其中包含多个文件和一个文件(file_list),其中列出了感兴趣的文件。我想创建符号链接,指向与列表中的文件名匹配的所有文件。在bash中有简单的方法吗?范例:
file_list
file1
file2
file3
file4
file5
file1, file3, file5
zvokhttg1#
类似这样的东西应该做:
#!/usr/bin/env bash while IFS= read -r file; do [[ -e /some/path/$file ]] && ln -s "/some/path/$file" /dest/path done < file_list
字符串
bejyjqdl2#
像这样的东西应该像cp -s制作符号链接一样工作
cp -s
cp -s $(cat file_list) /path/to/destination/dir/
2条答案
按热度按时间zvokhttg1#
类似这样的东西应该做:
字符串
bejyjqdl2#
像这样的东西应该像
cp -s
制作符号链接一样工作字符串