1
我正在嘗試將數據寫入文件。這是劇本。它很容易,也不正確。但是,請幫助我獲得輸出。將數據寫入文件
#!bin/ksh
DATE=date +'%m/%d/%Y'_$CNTR_SEQ
file1=$1 # Signifies DATE config file
file2=$2 # Signifies MONT config file
file3=$3 # Signifies YEAR config file
file4=$4 # Signifies SEQN config file
file5=$5 # Signifies FILETYPE config
file6=$6 # Signifies CNTR1 config file
file7=$7 # Signifies CNTR2 config file
for CNTR_DATE in {0..100}; do
for CNTR_SEQ in {1..4}; do
NEXT_DATE=$(date +%m-%d-%Y_$CNTR_SEQ -d "$DATE + $CNTR_DATE day")
echo $NEXT_DATE
if [ -f $5=TST ]; then
printf "$3-$2-$1|$4|\n0000000|0\n00000" > echo TST_$NEXT_DATE.dat
# This is the content of file.This should be the file creation with
# that date's name pattern.The contents of file is been written into
# a specific name pattern. Is this correct?
fi
cat /MYDIR/$echo
# A file is creating in the MYDIR /FILE_NAME path.
exit(0)
done
done
請修復格式。它看起來像你的問題文本以某種方式陷入了你的腳本中間。請注意格式化,閱讀格式不正確的問題確實非常困難。 – janos
您似乎沒有在任何地方設置$ DATE。 –
此外,您沒有結束}以匹配「if」語句前面的開頭行。 –