How to generate files named at current time under windows and Linux

Time:2020-4-19

Windows bat batch file:

Copy codeThe code is as follows:
@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 script:

Copy codeThe code is as follows:
#!/bin/sh
echo test >> $(date -d “today” +”%Y%m%d_%H%M%S”).txt