0
我已經制作了一個能夠完成我所要做的90%的腳本。它進入一個目錄(根據輸入的日期),它改變我送入數組的文件。但是,我想將此腳本更改爲還包含日期數組(這是目錄名稱)。它將在目錄中循環,當它從文件名數組中找到一個文件時,它會糾正它並繼續前進,直到所有文件都得到糾正。我已經嘗試了幾個不同的版本,但我不確定如何在文件更正後如何實現第二個數組以繼續查看目錄。如何使用shell腳本查看目錄和更改文件?
目前,我的劇本是這樣的:
debug=false
## *****Put file name in quotes******
declare -a arr=("UF19905217" "UG19905218")
##Put date in DDMMYYYY format for the date the message was original processed.
DATE="25082015"
## now loop through the above array
for i in "${arr[@]}"
do
#if "$debug; then
echo "Fix file named: Inbound_$i.msg"
MSG="Inbound_$i.msg"
#fi
if [ ! -d "$MSG" ]; then
# Enter what you would like changed here. You can copy and paste this command for multiple changes
#DATATYPE
printf "%s\n" ',s/<DataType>EDI<\/DataType>/<DataType>830<\/DataType>/g' wq | ed -s /data1/Inbound/$DATE/$MSG
echo "Complete"
else
echo "Message not found or errored!"
fi
done
我感謝所有幫助您可以提供。謝謝。
沒見過'ed'。尼斯。 – chepner