Appearance
Linux touch 命令
功能
创建/修改文件时间
语法格式
touch [选项] [文件]
常用参数
- -a:只更改访问时间
- -m:只更改修改时间
- -c:如果文件不存在,不创建
- -t:使用指定时间戳
- -r:使用参考文件的时间
使用示例
touch file1.txt file2.txt #创建文件
touch -c nonexistent.txt #不创建新文件
touch -a file1.txt #更改访问时间
touch -m file1.txt #更改修改时间
touch -t 202312011200.00 timefile.txt #指定时间
touch -r file1.txt file2.txt #同步时间
ls -l --time=atime file1.txt #查看访问时间
ls -l --time=mtime file1.txt #查看修改时间