我需要編寫一個shell腳本,每週由UNIX發送出去。我不知道如何在腳本中分配一個變量。下面是我的代碼如何在shell腳本中發送當前周
#!/bin/bash
OUTPUT_SUMMARY="weekly_updates.html"
WEEK_NUMBER = %V
YEAR = %Y
WORK_WEEK = YEAR.WEEK_NUMBER
echo "To:[email protected]">| $OUTPUT_SUMMARY
date "+Subject:Weekly Update - WW%U %Y">> $OUTPUT_SUMMARY
echo -e "Content-Type:text/html;charset:/"UTF-8/"">> $OUTPUT_SUMMARY
echo "<!doctype html>">> $OUTPUT_SUMMARY
echo "<html>">> $OUTPUT_SUMMARY
echo "<head>">> $OUTPUT_SUMMARY
echo -e "<meta http-equiv="content-type" content="text/html";charset=\"UTF-8\">">> $OUTPUT_SUMMARY
echo "</head>">> $OUTPUT_SUMMARY
echo "<body>">> $OUTPUT_SUMMARY
echo "<pre>">> $OUTPUT_SUMMARY
echo "I am in week $WORK_WEEK" >> $OUTPUT_SUMMARY
echo "</pre>">> $OUTPUT_SUMMARY
代碼給錯誤該行沒有發現這是WEEK_NUMBER,一年WORK_WEEK的聲明4,5,6的命令。如何聲明變量,以便我可以在代碼中使用它?
感謝@paxdiablo,它的工作原理! – Tim