Concat Variable (date) and String in shell unix - bash

前端 未结 3 704
Happy的楠姐
Happy的楠姐 2021-01-03 11:42

I\'m trying to concat a var (date) and string to have a file with current date name.

My code.

days=\"$(date +\"%Y%m%d_%H%M\")\"
echo \"SKIP\" > ${         


        
3条回答
  •  隐瞒了意图╮
    2021-01-03 12:48

    It works on my system (OS X) even with double quotes everywhere. For variation I used:

    $> days="$(date +'%Y%m%d_%H%M')"
    $> echo $days
    20160601_1051
    $> echo "SKIP" > ${days}_EMERGENCY.txt
    $> ll ${days}_EMERGENCY.txt
    -rw-r--r--  1 user  team  5 Jun  1 10:52 20160601_1051_EMERGENCY.txt
    

提交回复
热议问题