47
36

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

シェルスクリプトで日付と文字列を結合する

Posted at

たとえば、今日が20161031だとして、

article_2016103.txt

という文字列をシェルスクリプトで生成する方法です。

today=$(date "+%Y%m%d")
echo "article_${today}.txt"
# => article_20161031.txt

または、以下のようにも書けるけど、$ の方を使う方が良いらしい。

today=`date "+%Y%m%d"`
echo "article_${today}.txt"
# => article_20161031.txt

おわり。 :thought_balloon:

47
36
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
47
36

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?