date获取系统时间,"+%Y_%m_%d_%H_%M_%S"指定格式,$time 输出时间, ~/Desktop/ $newFile指定位置下的文件夹
#!/bin/bash
time=$(date "+%Y_%m_%d_%H_%M_%S")
newFile=$time".log"
echo $time > ~/Desktop/$newFile
本文介绍了如何在Bash脚本中使用`date`命令获取当前系统时间并按照特定格式生成新的.log文件,保存到~/Desktop/指定文件夹中。
date获取系统时间,"+%Y_%m_%d_%H_%M_%S"指定格式,$time 输出时间, ~/Desktop/ $newFile指定位置下的文件夹
#!/bin/bash
time=$(date "+%Y_%m_%d_%H_%M_%S")
newFile=$time".log"
echo $time > ~/Desktop/$newFile
2148
2万+

被折叠的 条评论
为什么被折叠?