Bash 脚本:目录中的所有文件
Bash Script: All files in directory
我是一名编码新手,在编写 bash 脚本时遇到了问题,在该脚本中,我的目录(number001.log、number002.log 等)中的所有日志文件都通过以下方式进行处理一个 perl 脚本 (map_shifts2PDB.pl) 和每个 numberXXX.log 文件的结果连接到一个 results.out 文件。 perl 脚本需要以下参数 ./map_shifts2PDB.pl <path of logfile> <path of test.pdb> (constant)
和要处理的日志文件的编号。我不知道如何将它同步到循环中正在读取的日志文件。这是我目前所拥有的:
#!/bin/bash
for f in ~/TrpCage_1L2Y/1L2Y_min_explicit/model1_charged/calculate/*.log; do
./map_shifts2PDB.pl ~/TrpCage_1L2Y/1L2Y_min_explicit/model1_charged/calculate ~/TrpCage_1L2Y/1L2Y
_min_explicit/model1_charged/test.pdb 1 >> results.out
done
只需使用参数扩展从文件名中提取数字:
num=${f##*/number} # Delete everything up to /number.
num=${num%.log} # Delete the extension.
./map_shifts2PDB.pl \
~/TrpCage_1L2Y/1L2Y_min_explicit/model1_charged/calculate \
~/TrpCage_1L2Y/1L2Y_min_explicit/model1_charged/test.pdb \
$num >> results.out
标题中的"recursive"是什么意思?
我是一名编码新手,在编写 bash 脚本时遇到了问题,在该脚本中,我的目录(number001.log、number002.log 等)中的所有日志文件都通过以下方式进行处理一个 perl 脚本 (map_shifts2PDB.pl) 和每个 numberXXX.log 文件的结果连接到一个 results.out 文件。 perl 脚本需要以下参数 ./map_shifts2PDB.pl <path of logfile> <path of test.pdb> (constant)
和要处理的日志文件的编号。我不知道如何将它同步到循环中正在读取的日志文件。这是我目前所拥有的:
#!/bin/bash
for f in ~/TrpCage_1L2Y/1L2Y_min_explicit/model1_charged/calculate/*.log; do
./map_shifts2PDB.pl ~/TrpCage_1L2Y/1L2Y_min_explicit/model1_charged/calculate ~/TrpCage_1L2Y/1L2Y
_min_explicit/model1_charged/test.pdb 1 >> results.out
done
只需使用参数扩展从文件名中提取数字:
num=${f##*/number} # Delete everything up to /number.
num=${num%.log} # Delete the extension.
./map_shifts2PDB.pl \
~/TrpCage_1L2Y/1L2Y_min_explicit/model1_charged/calculate \
~/TrpCage_1L2Y/1L2Y_min_explicit/model1_charged/test.pdb \
$num >> results.out
标题中的"recursive"是什么意思?