运行 使用 qsub 的多个具有唯一名称的作业

Running multiple jobs with unique name using qsub

我有一堆名为

的文本(输入)文件
foo_bar_abc_1_01_geh_file.in
foo_bar_abc_1_02_geh_file.in
foo_bar_abc_1_03_geh_file.in
...
...
foo_bar_abc_1_1000_geh_file.in

我使用以下命令 运行 这些多个作业(在 HPC 集群中)

for f in foo*.in; do qsub -N test -v infile=$f run.pbs

这个单行脚本中的问题是作业名称(在集群中)对于队列中的所有作业都是相同的(即,test 是所有作业的名称)。

我想将每个作业命名为 test01、test02、test03...test1000(相应文件名中的数字 taken/extracted。例如,

   #For foo_bar_abc_1_01_geh_file.in, the Job Name should be test01,   
   #For foo_bar_abc_1_02_geh_file.in, the Job Name should be test02,   
   #For foo_bar_abc_1_100_geh_file.in, the Job Name should be test100,
   etc.

如何做到这一点bash?

你可以使用cut喜欢

for f in foo*.in; do qsub -N test$(echo $f|cut -d_ -f5) -v infile=$f run.pbs; done

哪里

  • -d_ 将分隔符设置为 _
  • -f5 select 仅第 5 列(即职位编号)