強く打つ
#!/bin/bash
echo "Please enter your name."
read name
then
echo "Good day $name, here is your calendar for this month:"
cal
echo "Today is" `date +%A`
if test $date -lt friday
then
echo "TGIF"
fi
ベストアンサー1
必要な権限は実行権限です。しかし、スクリプトにいくつかのエラーがあります。実行してみると、最初のエラーがはっきりと表示されます。
$ chmod u+x jason.sh
$ ./jason.sh
Please enter your name.
Jason
./jason.sh: line 4: syntax error near unexpected token `then'
./jason.sh: line 4: `then'
修正してやり直してください。
$ ./jason.sh
Please enter your name.
Jason
Good day Jason, here is your calendar for this month:
February 2020
Su Mo Tu We Th Fr Sa
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
Today is Friday
./jason.sh: line 7: test: -lt: unary operator expected
このように日付を比較することはできません。確認してください。シェルで2つの日付を比較するには?