Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
最後の日曜日の日付を取得するにはdate --date="last sun"、Linux とdate -j -v-sunBSD に使用できます。
date --date="last sun"
date -j -v-sun
ただし、文字列の代わりに週番号 (1 ~ 7) がある場合はどうすればよいですか? ケースステートメントを使用して数値を文字列に変換することはいつでもできますが、これにはもっと良い解決策があるのではないでしょうか?!
ご協力いただきありがとうございます。
配列を使用します。
number=1 days=(zero sun mon tue wed thu fri sat) date --date="last ${days[number]}"