我需要尋找具有相同tittles(但不是擴展名!)的文件對的2個dirs,並在某個新命令中合併它們的標題。關於尋找相同的文件對
第一如何打印文件
1)通常我用在for循環以下命令的唯一名稱來選擇爲循環
for file in ./files/* do;
title=$(base name "file")
print title
done
文件的全名,我應該怎麼在上面的腳本中更改爲只打印文件名稱的標題而不打印其擴展名?
2)如何其可能添加一些條件來檢查兩個文件是否具有相同的名字對他們進行雙循環E,G
# counter for the detected equal files
i=0
for file in ./files1/* do;
title=$(base name "file") #change it to avoid extension within the title
for file2 in ./files2/* do;
title2=$(basename "file2") #change it to avoid extension within the title2
if title1==title2
echo $title1 and $title2 'has been found!'
i=i+1
做
感謝您的幫助! Gleb
請看http://www.shellcheck.net/ – Cyrus 2015-02-07 10:18:02