Last active
December 24, 2018 10:24
-
-
Save na0AaooQ/7b7652ba10df4affa0f5 to your computer and use it in GitHub Desktop.
dateコマンドでバックアップファイル作成時にファイル名に日付_時間を付ける (LinuxとWindows用) ref: https://qiita.com/na0AaooQ/items/c26b637261d9962f981f
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cp -p バックアップ対象ファイル名 バックアップファイル名.`date "+%Y%m%d_%H%M%S"` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
D:\> copy バックアップ対象ファイル名 バックアップファイル名.%date:~0,4%%date:~5,2%%date:~8,2%_%time:~0,2%%time:~3,2%%time:~6,2% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# date | |
Fri Jan 23 02:48:40 JST 2015 | |
# date "+%Y%m%d_%H%M%S" | |
20150123_024843 | |
# cp -p /etc/fstab /etc/fstab.`date "+%Y%m%d_%H%M%S"` | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ll /etc/fstab.20150123_024858 | |
-rw-r--r--. 1 root root 584 Oct 3 01:59 /etc/fstab.20150123_024858 | |
# | |
# ll /etc/fstab | |
-rw-r--r--. 1 root root 584 Oct 3 01:59 /etc/fstab | |
# | |
# diff /etc/fstab /etc/fstab.20150123_024858 | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
D:\tools>echo %date% | |
2018/12/24 | |
D:\tools>echo %time% | |
19:06:28.93 | |
D:\tools> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
D:\tools>echo %date:~0,4%%date:~5,2%%date:~8,2%_%time:~0,2%%time:~3,2%%time:~6,2% | |
20181224_190612 | |
D:\tools> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
D:\tools>copy example.txt example.txt.%date:~0,4%%date:~5,2%%date:~8,2%_%time:~0,2%%time:~3,2%%time:~6,2% | |
1 個のファイルをコピーしました。 | |
D:\tools> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
D:\tools>dir | |
(中略) | |
D:\tools のディレクトリ | |
2018/12/24 19:09 <DIR> . | |
2018/12/24 19:09 <DIR> .. | |
2018/12/24 19:01 4 example.txt | |
2018/12/24 19:01 4 example.txt.20181224_190922 | |
(中略) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment