Chinaunix首页 | 论坛 | 博客
  • 博客访问: 142847
  • 博文数量: 19
  • 博客积分: 475
  • 博客等级: 下士
  • 技术积分: 273
  • 用 户 组: 普通用户
  • 注册时间: 2010-09-13 14:52
文章分类
文章存档

2012年(2)

2011年(17)

我的朋友

分类: Python/Ruby

2011-09-25 16:13:02

转载自深度VPS [ ] 

在 Windows、Linux 操作系统,分别利用BAT批处理文件和Shell脚本,生成类似“2011071_082905.txt”以“年月日_时分秒”命名的文件。

Windows BAT批处理文件:

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

Linux Shell 脚本:

  1. #!/bin/sh
  2. echo test >> $(date -d "today" +"%Y%m%d_%H%M%S").txt
阅读(1892) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~