Linux -- touch 创建及修改文件时间
TOUCH(1) User Commands TOUCH(1)
NAME 名称
touch - change file timestamps 修改文件时间戳
SYNOPSIS 大纲(语法)
touch [OPTION]... FILE...
DESCRIPTION 说明
Update the access and modification times of each FILE to the current time.
更新每个文件的访问时间和修改时间为当前时间。
A FILE argument that does not exist is created empty, unless -c or -h is supplied.
除非指定-c或-h参数,否则当FILE参数所指向的文件不存在时,将创建一个空文件。
A FILE argument string of - is handled specially and causes touch to change the times of the file associated with standard output.
Mandatory arguments to long options are mandatory for short options too.
对于长选项必须的参数,对于短选项也是必须的。
-a
change only the access time
只修改访问时间。
-c, --no-create
do not create any files
不创建任何文件。
-d, --date=STRING
parse STRING and use it instead of current time
解析STRING,并使用它代替当前时间。
-f (ignored)
-h, --no-dereference
affect each symbolic link instead of any referenced file (useful only on systems that can change the timestamps of a symlink)
只影响符号连接文件本身,而不影响任何被引用的文件(通常只针对可以改变符号连接文件时间戳的系统)。
-m
change only the modification time
只修改'修改时间。
-r, --reference=FILE
use this file's times instead of current time
使用此文件的时间代替当前时间。
-t STAMP
use [[CC]YY]MMDDhhmm[.ss] instead of current time
使用[[CC]YY]MMDDhhmm[.ss]格式字符串代替当前时间。
--time=WORD
change the specified time: WORD is access, atime, or use: equivalent to -a; WORD is modify or mtime: equivalent to -m
修改指定的时间:当WORD=access, atime, or use时,等价于-a;当WORD=modify or mtime时,等价于-m。
--help display this help and exit
显示此命令的帮助信息并退出。
--version
output version information and exit
显示版本信息并退出。
Note that the -d and -t options accept different time-date formats.
-d与-t选项所接受的日期时间格式不同。
GNU coreutils online help: <http://www.gnu.org/software/coreutils/> Report touch translation bugs to <http://translationproject.org/team/>
DATE STRING
The --date=STRING is a mostly free format human readable date string such as "Sun, 29 Feb 2004 16:21:42 -0800" or "2004-02-29 16:21:42" or even "next Thursday". A date string may contain items indicating calendar date, time of day, time zone, day of week, relative time, relative date, and numbers. An empty string indicates the beginning of the day. The date string format is more complex than is easily documented here but is fully described in the info documentation.
--date=STRING指定的字符串通常是人类能够轻易识别的绝大多数自由格式的字符串。例如:"Sun, 29 Feb 2004 16:21:42 -0800"或"2004-02-29 16:21:42"甚至"next Thursday"。日期字符串可以包含日历日期、时间、时区、周、相对时间、相对日期、数字等项目。空字符串表示当前天的开始。日期字符串格式比这里容易记录的复杂得多,但在info文档中有完全描述。
AUTHOR
Written by Paul Rubin, Arnold Robbins, Jim Kingdon, David MacKenzie, and Randy Smith.
COPYRIGHT
Copyright (C) 2013 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
SEE ALSO
The full documentation for touch is maintained as a Texinfo manual. If the info and touch programs are properly installed at your site, the command
info coreutils 'touch invocation'
should give you access to the complete manual.
touch的完整文档是以Texinfo手册形式维护的。如果info和touch程序都已经安装,那么执行命令:
info coreutils 'touch invocation'
应该会让你访问到整篇手册。
GNU coreutils 8.22 June 2014 TOUCH(1)
案例:
一、查看文件详细时间信息方式
[root@user test]# ll total 4 -rw-r--r-- 1 root root 3072 Mar 6 21:22 test [root@user test]# stat test File: 'test' Size: 3072 Blocks: 8 IO Block: 4096 regular file Device: fd01h/64769d Inode: 65556 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2017-03-06 21:22:44.693495766 +0800 Modify: 2017-03-06 21:22:44.693495766 +0800 Change: 2017-03-06 22:40:59.432269895 +0800 Birth: - [root@user test]#
二、修改test的访问时间为‘2017-03-06 20:00:00’
[root@user test]# touch -a -d '2017-03-06 20:00:00' test [root@user test]# stat test File: 'test' Size: 3072 Blocks: 8 IO Block: 4096 regular file Device: fd01h/64769d Inode: 65556 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2017-03-06 20:00:00.000000000 +0800 Modify: 2017-03-06 21:22:44.693495766 +0800 Change: 2017-03-06 22:43:48.309459980 +0800 Birth: - [root@user test]#
相关推荐
linux touch命令详解: 1、命令功能: 创建文件和修改文件或者目录的时间戳 2、命令语法: touch 【选项】 【文件名或者目录名】 3、命令参数: -a 只修改文件的access(访问)时间. -c 或–no-create 不创建不存在的...
Linux touch命令 Linux touch命令用于修改文件或者目录的时间属性,包括存取时间和更改时间。若文件不存在,系统会建立一个新的文件。 ls -l 可以显示档案的时间记录。 语法 touch [-acfm][-d][-r] [-t][--help][-...
touch 命令用于创建空文件,也可以更改 Unix 和 Linux 系统上现有文件时间戳。这里所说的更改时间戳意味着更新文件和目录的访问以及修改时间。 让我们来看看 touch 命令的语法和选项: 语法: # touch {选项} {文件...
12. touch 13. cp 14. mv 15. rm 16. find 17. grep 18. more 19. less 20. head 21. tail 22. cut 23. at 24. crontab 25. sleep 26. kill 27. ps pstree 28. top 29. expr 30. locate 31. split 33. man,info 34....
可以直接打印 共11页 第一章 目录及文件操作命令 2 1.1 ls 2 1.2 pwd 2 1.3 cd 2 1.4 mkdir 2 1.5 rmdir 2 1.6 cat 2 1.7 head 2 1.8 more 2 1.9 cp 3 1.10 mv 3 ...1.19 touch 4 ...UNIX的Shell命令详解 10
Linux常用命令 – 已学 cd (路径的切换) rm(后接-rf 可删除文件或文件夹) ls(查看当前路径下的文件和文件夹) mkdir(创建文件夹) touch(创建文件) cat(查看文件内容)mv (移动文件,也可以重命名...
Linux常用命令总结,详解。包含:pwd、cd、grep、touch、cat、rm、vi等命令。 学习掌握后,定能让你日常使用Linux中得心应手。且面试时也不怕再被问到了。
大数据基础-Linux基础详解课程
主要介绍了 linux touch,chattr指令详解几用法的相关资料,需要的朋友可以参考下
touch:创建新文件或更改文件的时间戳。 cat:显示文件内容。 head:显示文件的前几行。 tail:显示文件的后几行。 grep:在文件中查找指定的字符串。 find:在文件系统中查找文件或目录。 chmod:修改文件或目录的...
Touch 创建文件 mv 移动文件 Rm 删除文件 rmdir 删除目录 Vi 编辑文件 1.1 pwd命令 该命令的英文解释为print working directory(打印工作目录)。输入pwd命令,Linux会输出当前目录。 1.2 cd命令 用来改变所在目录...
例如,查找 touch 命令 [root@node1 /]# whereis touch touch: /usr/bin/touch /usr/share/man/man1/touch.1.gz 执行效果如下: 如果只需要查找 touch 命令的二进制文件,可以使用 -b 选项实现: [root@node1...
3、 Linux目录详解 三、 命令概述 1、 常用快捷键 2、 Linux 终端命令格式 2.1 终端命令格式 2.2 查阅命令帮助信息 2.3 文件和目录常用命令 2.3.1 查看目录内容 2.3.2 ls命令 2.3.3 nd指令 2.4 相对路径和绝对路径 ...
第1章 UNIX操作系统概述 7 1.1 UNIX操作系统简介 7 1.2 UNIX系统组成 7 1.3 UNIX启动过程 8 1.4 UNIX用户登录过程 8 1.5 与UNIX有关的几个名词 9 第2章 UNIX基本常识 11 2.1 启动终端 11 ...6.4 grep命令详解 99
ls 命令详解:超级详细,包含文件权限内容 注意: 博客使用的linux版本:CentOS Linux release 7.7.1908 (Core) 介绍命令时先介绍最常见的,同功能的命令也会涉及 一、mkdir 创建目录 简介:mkdir命令是“make ...
本文主要对stat和touch两个命令进行讲解。 如何查看一个文件的元数据呢?可以使用stat命令。 File: ‘ceshi1’ 文件所在路径 Size: 4096 Blocks: 8 文件占据的磁盘块 IO Block: 4096 directory 文件类型 ...
一、 Touch包0x91 a) 0x2aa8 客户端 原始数据: 02 11 5b 00 91 2a a8 38 25 f5 91 5d 4c af 65 54 44 6d 76 7b ff f0 14 73 e6 0a 95 9d 74 ce b3 b5 fd 61 1d 12 84 a5 04 53 3c b1 d4 f9 27 9c 7c 3f ef f0 bb 3c...
&& 与 || 配合 eg: cat test.sh #!/bin/bash [ -e /etc/hosts ] && echo ok || echo fail bash test.sh ok eg: cat test.sh ...[ -f /home/tecmint/Downloads/xyz1.txt ] || {touch /home/tecmint/Downloa
您可能感兴趣的文章:linux touch,chattr指令详解及用法详解Linux命令修改文件的三个时间Linux C字符串替换函数实例详解linux 详解useradd 命令基本用法Linux shell命令帮助格式详解Linux shell