Windows和 Linux下生成以当前时间命名文件的方法

2019-01-30 04:55:12刘景俊
Windows BAT批处理文件:

@echo off
set time_hh=%time:~0,2%
if /i %time_hh% LSS 10 (set time_hh=0%time:~1,1%)
set filename=%date:~,4%%date:~5,2%%date:~8,2%_%time_hh%%time:~3,2%%time:~6,2%
echo test >> %filename%.txt

Linux Shell 脚本:

#!/bin/sh
echo test >> $(date -d "today" +"%Y%m%d_%H%M%S").txt

您可能感兴趣的文章:

Linux下date命令,格式化输出,时间设置方法解析Linux下的时间函数:设置以及获取时间的方法Linux 按时间批量删除文件命令(删除N天前文件)linux获取进程执行时间方法示例程序中获取linux系统启动时间方法基于linux下获取时间函数的详解linux获取系统启动时间示例详解Linux 判断文件修改时间和系统时间差Linux/Unix关于时间和时间戳的命令行Linux系统中时间的获取和使用
相关文章 大家在看