gpt4 book ai didi

date - 系统日期到可变unix

转载 作者:行者123 更新时间:2023-12-04 23:23:56 25 4
gpt4 key购买 nike

我想运行以下脚本

#!/bin/sh
temp =`date +%Y%m%d`
echo "$temp"

但这并没有按预期运行
它正在抛出此错误消息临时:执行权限被拒绝

最佳答案

你有

temp =`date +%Y%m%d`
^

所以你需要去掉 temp之间的空格和 date :
#!/bin/sh
temp=$(date +%Y%m%d) # better than `exp`, thanks @OliverDulac (see comments)
echo "$temp"

有了这个,它对我有用。

确保文件具有执行权限:
chmod +x your_file

或者只是执行它
/bin/sh /your/script/path/your_file

关于date - 系统日期到可变unix,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16769255/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com