当前位置:首页 > linux > 正文

linux新建文件用什么命令

  • linux
  • 2024-05-09 21:14:18
  • 4021

touch 命令用于创建新文件或更新现有文件的时间戳。
语法:
touch [-a|-c|-d|-f|-m|-t|-r|-v] [选项] 文件名...
选项:
-a 更新访问时间戳。
-c 仅在文件不存在时创建文件。
-d 设置时间戳。 格式为:YYYY-MM-DDThh:mm:ss。
-f 强制创建文件,即使文件已存在。
-m 更新修改时间戳。
-t 设置时间戳。 格式为:seconds since the Epoch。
-r 从另一个文件复制时间戳。
-v 显示详细输出。
示例:
创建新文件名为 "myfile.txt" 的文件:
touch myfile.txt
更新文件名为 "myfile.txt" 的文件的时间戳:
touch -m myfile.txt
设置文件名为 "myfile.txt" 的文件的时间戳为 2023 年 1 月 1 日 12:00 AM:
touch -t 1672531200 myfile.txt
仅在文件名为 "myfile.txt" 的文件不存在时创建该文件:
touch -c myfile.txt