0
我將下面的shell腳本輸出爲電子郵件。 其中的文件名稱時間大小。如何在linux shell腳本輸出中縮短文件路徑
pint文件名我得到整個目錄太長。
有些如何保留最後一個或兩個目錄名和文件名。 ?
#!/bin/bash
monitor_dir=/path/to/dir
[email protected]
files=$(find "$monitor_dir" -maxdepth 1 | sort)
IFS=$'\n'
while true
do
sleep 5s
newfiles=$(find "$monitor_dir" -maxdepth 1 | sort)
added=$(comm -13 <(echo "$files") <(echo "$newfiles"))
[ "$added" != "" ] &&
find $added -maxdepth 1 -printf '%Tc\t%s\t%p\n' |
mail -s "incoming" "$email"
files="$newfiles"
done
我們怎麼可以把這個技術在我發佈的代碼 – Readerlook