别名命令 "date -d @" 无法在 Mac 上接受 $1

alias command "date -d @" can not accept $1 on Mac

the command in bash_profile

alias getTime1='date -d @1490170832 +"%F %H:%M:%S"'

alias getTime2='date -d @'

but in terminal it not work

唐纳德林@~$getTime1

2017-03-2216:20:32

donaldlin@~$getTime2 1490170832

日期:参数‘1490170832’缺少前导‘+’; 使用选项指定日期时,任何非选项 参数必须是以“+”开头的格式字符串 尝试 'date --help' 了解更多信息。

我试了"date -d @$1","date -d @''","date -d ${@}"等等,还是不行

更新: aliases 不能带参数。您需要创建一个函数 感谢@chepner 和@l0b0

aliases 不能带参数。您需要创建一个函数。