【问题标题】:access large number of filenames访问大量文件名
【发布时间】:2014-07-22 19:17:16
【问题描述】:

我有 100 个目录,每个目录中包含 1 个文件,我需要一起访问所有 100 个文件,例如

hadd 1/result1.root 2/result2.root ........100/result100.root.

我可以打印出名字(我已经做了如下所示)但是如何一起使用这些名字呢?

#!/bin/bash

for dset in {1..101}
do
    #echo $dset/results$dset.root
    ls -l $dset/*.root | awk '{printf("%s", $9)}'
done

由于我没有在数组中保存任何内容,如何调用文件名?

【问题讨论】:

    标签: arrays bash loops


    【解决方案1】:
    ls -1 {1..101}/*.root | xargs echo hadd
    

    当您对输出感到满意时,删除 echo 部分。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-09-28
      • 1970-01-01
      • 2016-11-20
      • 1970-01-01
      • 1970-01-01
      • 2021-05-28
      相关资源
      最近更新 更多