【问题标题】:Loop through list of files and ack sourcecode to see if files are still used循环遍历文件列表和 apk 源代码以查看文件是否仍在使用
【发布时间】:2013-11-30 21:18:50
【问题描述】:

我有一个 txt 文件,其中包含大量旧的 jquery 插件文件名,每个文件名都在一个新行上。理想情况下,我将能够遍历这个文件名列表,并在我的源代码中确认哪些文件仍在使用这些库,同时说明频率。如果它们输出到 TSV 中会有所帮助。

list=file_read(list_of_files.txt);
for (i in list) {
  print "\r\n"+i+"\r\n\t";
  ack -Hclw i
}

理想的输出应该是这样的:

jquery.easing.1.3.js
    file1.js:2
    file5.js:5
    file7.js:2
jquery.form.js
    file1.js:1
jquery.metadata.js
    file1.js:1
    file1.js:1
jquery.pajinate.js
    file1.js:2
    file3.js:2
jquery.tooltip.js
    file3.js:5
jquery.tzCheckbox.js
    file1.js:4
    file4.js:2
    file8.js:1

非常感谢各位!我可以在 php 中的脚本中执行此操作,但无法在 ack 中全部弄清楚。我很确定 ack 有能力做到这一点,但在阅读手册后已经干涸了。

【问题讨论】:

    标签: shell command-line grep ack


    【解决方案1】:

    也许你正在寻找这个:

    while read plugin; do
        echo $plugin:
        ack -Hclw $plugin /path/to/source | sed -e 's/^/    /'
    done < list_of_files.txt
    

    【讨论】:

      猜你喜欢
      • 2019-08-05
      • 1970-01-01
      • 1970-01-01
      • 2021-02-20
      • 2020-10-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-19
      • 2020-09-06
      相关资源
      最近更新 更多