复制成功
请遵守本站许可
REPORT
Chapter_Post // Field_Report

Post_Ref: RL-LINUX每日命

2026.04.08

Linux每日命令-87-touch

Echo HaoRan
Echo HaoRan
#计划任务
ANALYSIS

Linux 每日一篇 - 87 - touch#

Linux 时间戳修改神器!掌握 touch 命令,轻松修改文件时间,创建空文件,管理文件状态!

touch 命令是什么?#

touch 命令用于修改文件的访问时间和修改时间戳,如果文件不存在则创建空文件,是文件时间管理的基本工具。

基本用法#

PRTCL // PLAINTEXT
# 创建空文件或更新时间戳
touch filename
# 更新多个文件的时间戳
touch file1 file2 file3
# 设置特定时间戳
touch -t 202601231200 filename
# 设置特定日期时间
touch -d "2026-01-23 12:00:00" filename
# 复制时间戳从另一个文件
touch -r reference_file target_file
# 只更新访问时间
touch -a filename
# 只更新修改时间
touch -m filename
# 不创建不存在的文件
touch -c filename

实用技巧#

PRTCL // PLAINTEXT
# 创建多个空文件
touch file1.txt file2.txt file3.txt
# 更新文件到当前时间
touch existing_file.txt
# 创建带特定时间戳的文件
touch -d "yesterday" yesterday_file.txt
# 复制文件的时间戳
touch -r source.txt target.txt
# 设置文件为特定时间
touch -t 12312359 desired_time_file.txt # 12 月 31 日 23:59
# 检查 touch 后的效果
touch testfile && stat testfile
# 批量更新文件时间
touch *.log
# 在脚本中使用 touch 作为标记
touch /tmp/script_running.flag

常用场景#

PRTCL // PLAINTEXT
# 创建临时文件
touch /tmp/temp_file.txt
# 更新 makefile 依赖时间(强制重新编译)
touch source.c
# 创建日志文件
touch /var/log/myapp.log
# 设置文件时间用于测试
touch -d "2026-06-15" test_file.txt
# 复制文件时间戳
touch -r original.conf backup.conf
# 更新配置文件时间戳以触发服务重启
touch /etc/myapp/config
# 创建多个空文件用于占位
touch {1..10}.txt
# 在脚本中创建锁文件
touch /tmp/myscript.lock
# 脚本结束时删除锁文件
rm /tmp/myscript.lock

抖音文案#

🎯 Linuxtouch 命令!

✅ 基本用法:touch ✅ 常用参数:touch -option ✅ 实用技巧:touch —help

每天一个 Linux 命令,30 天变身 Linux 高手!

#Linux 入门 #文件命令 #程序员必备 #技术分享


关于我#

全平台同名”汪多多是只猫”,专注分享实用技术教程,让你的 IT 学习之路更轻松!

关注我,每天一个 Linux 命令,轻松入门 Linux 系统!

R P
Rhine Lab Pioneer Division
Auth_Verified: 2026.04.08
// END OF POST

订阅

通过 RSS 订阅本站,新文章发布时第一时间收到通知。

Follow
Classified
Chapter_06
Protocol_Ref: CC-BY-NC-SA-4.0

Linux每日命令-87-touch

Author: CHONGXIReleased: 2026.04.08

Licensed under CC BY-NC-SA 4.0

评论

© 2025-2026 EchoSpace
Powered by Astro & echohaoran Non-Collaborative_Entity // Protocol_V.4.21