我有一組目錄,我想搜索,即猛砸搜索和複製使用變量
/home/*/Documents/Crashes
,我想拉這些文件的格式爲:
A.log.20121022T160949Z
,其中前幾個數字是日期(這裏是2012/10/22)。
我有一個文本文件,我從用戶名拉入,以$ line的形式讀入。
我只想從當前日期提取文件。我已經嘗試過了:
D= date +%Y%m%d%t
cp -ru /home/$line/Documents/Crashes/A.log.$D* /home/$USER/Documents/Todayslogs
它將所有東西都拉出來。也試過找到沒有運氣...
我做錯了什麼?
我做了你所提到的調整。但是,現在 D = $(日期+%Y%m%d%t) cp -ru /home/$line/Documents/Crashes/A.log.$D*/home/ $ USER/Documents/Todayslogs 從/ home/$ USER/Documents中提取所有文件並將它們放入 /home/$ USER/Documents/Todayslogs – user1777905