touch
touch 文件,如果文件不存在,则创建一个新文件;如果文件存在,则将该存在的文件的修改时间或创建时间改为当前时间
touch -t 时间戳 文件,则把该文件的时间改了
-
一天一个shell命令 linux文本操作系列-touch命令用法
2020-09-15 15:32:31主要介绍了一天一个shell命令 linux文本操作系列-touch命令用法 ,需要的朋友可以参考下 -
Linux touch命令用法详解
2021-01-09 20:40:26Linux touch命令 Linux touch命令用于修改文件或者目录的时间属性,包括存取时间和更改时间。若文件不存在,系统会建立一个新的文件。 ls -l 可以显示档案的时间记录。 语法 touch [-acfm][-d][-r] [-t][--help][-... -
linux touch命令用法实例
2021-01-10 15:10:35linux touch命令详解: 1、命令功能: 创建文件和修改文件或者目录的时间戳 2、命令语法: touch 【选项】 【文件名或者目录名】 3、命令参数: -a 只修改文件的access(访问)时间. -c 或–no-create 不创建不存在的... -
touch命令的用法
2016-02-20 22:56:00touchtouch 文件,如果文件不存在,则创建...如果文件存在,则将该存在的文件的修改时间或创建时间改为当前时间touch -t 时间戳 文件,则把该文件的时间改了 转载于:https://www.cnblogs.com/yiyezc/p/5204195.html...转载于:https://www.cnblogs.com/yiyezc/p/5204195.html
-
touch命令
2019-05-18 18:21:09新增文件最常见的是用touch命令 用法 : touch [OPTION]… FILE… 把每个文件的访问时间和修改时间更新为当前时间 如果文件不存在,且没有用 -c 或-h 选项,则创建一个空文件, [root@chiji51 ~]# ls anaconda-...新增文件最常见的是用touch命令
用法 : touch [OPTION]… FILE…
把每个文件的访问时间和修改时间更新为当前时间
如果文件不存在,且没有用 -c 或-h 选项,则创建一个空文件,[root@chiji51 ~]# ls anaconda-ks.cfg Desktop Downloads Music Public Videos a.txt Documents initial-setup-ks.cfg Pictures Templates [root@chiji51 ~]# touch b.txt [root@chiji51 ~]# ls -l b.txt -rw-r--r--. 1 root root 0 May 12 19:43 b.txt
-a 把访问时间改成当前时间
[root@chiji51 ~]# stat a.txt Access: 2017-05-02 00:00:00.000000000 +0800 Modify: 2017-05-02 00:00:00.000000000 +0800 Change: 2019-05-12 18:24:02.604285661 +0800 [root@chiji51 ~]# touch -a a.txt [root@chiji51 ~]# stat a.txt Access: 2019-05-12 19:46:58.199585895 +0800 此处时间已经修改为当前时间 Modify: 2017-05-02 00:00:00.000000000 +0800 Change: 2019-05-12 19:46:58.199585895 +0800
-c, --no-create 不会创建任何文件
[root@chiji51 ~]# ls anaconda-ks.cfg b.txt Documents initial-setup-ks.cfg Pictures Templates a.txt Desktop Downloads Music Public Videos [root@chiji51 ~]# touch -c c.txt [root@chiji51 ~]# ls anaconda-ks.cfg b.txt Documents initial-setup-ks.cfg Pictures Templates a.txt Desktop Downloads Music Public Videos 当前目录没有c.txt
-d, --date=STRING 把atime 和mtime 时间改成STRING对应的时间,而不是当前时间
stat a.txt Access: 2019-05-12 19:46:58.199585895 +0800 Modify: 2017-05-02 00:00:00.000000000 +0800 Change: 2019-05-12 19:46:58.199585895 +0800 [root@chiji51 ~]# touch -d "20170512" a.txt [root@chiji51 ~]# stat a.txt Access: 2017-05-12 00:00:00.000000000 +0800 此时时间已经变成修改的时间 Modify: 2017-05-12 00:00:00.000000000 +0800 此时时间已经变成修改的时间 Change: 2019-05-12 19:52:00.054604109 +0800
-h, --no-dereference 将改变符号链接文件而不是实际的文件,不加-h将会改变符号链接文件和实际文件
[root@chiji51 ~]# ln -s Desktop/ desktop [root@chiji51 ~]# ls -ld Desktop desktop lrwxrwxrwx. 1 root root 8 May 12 19:57 desktop -> Desktop/ drwxr-xr-x. 2 root root 6 May 12 19:33 Desktop [root@chiji51 ~]# stat desktop Access: 2019-05-12 19:57:33.674624240 +0800 Modify: 2019-05-12 19:57:32.662624179 +0800 Change: 2019-05-12 19:57:32.662624179 +0800 [root@chiji51 ~]# stat Desktop Access: 2019-05-12 19:42:31.991569831 +0800 Modify: 2019-05-12 19:33:09.247535875 +0800 Change: 2019-05-12 19:33:09.247535875 +0800 [root@chiji51 ~]# touch -h desktop [root@chiji51 ~]# stat desktop Access: 2019-05-12 19:58:46.791628652 +0800 Modify: 2019-05-12 19:58:45.774628591 +0800 Change: 2019-05-12 19:58:45.774628591 +0800 此时链接文件的时间已经更改了 [root@chiji51 ~]# stat Desktop Access: 2019-05-12 19:42:31.991569831 +0800 Modify: 2019-05-12 19:33:09.247535875 +0800 Change: 2019-05-12 19:33:09.247535875 +0800
-m 把修改时间改成当前时间
[root@chiji51 ~]# stat a.txt Access: 2017-05-12 00:00:00.000000000 +0800 Modify: 2017-05-12 00:00:00.000000000 +0800 Change: 2019-05-12 19:52:00.054604109 +0800 [root@chiji51 ~]# touch -m a.txt [root@chiji51 ~]# stat a.txt Access: 2017-05-12 00:00:00.000000000 +0800 Modify: 2019-05-12 20:09:21.341666942 +0800 此时时间已经变成当前的时间 Change: 2019-05-12 20:09:21.341666942 +0800
-r, --reference=FILE 对照该文件的时间,把另外一个文件的时间改成该文件的时间
[root@chiji51 ~]# stat a.txt Access: 2017-05-12 00:00:00.000000000 +0800 Modify: 2019-05-12 20:09:21.341666942 +0800 Change: 2019-05-12 20:09:21.341666942 +0800 [root@chiji51 ~]# stat b.txt Access: 2019-05-12 19:43:33.903573567 +0800 Modify: 2019-05-12 19:43:33.903573567 +0800 Change: 2019-05-12 19:43:33.903573567 +0800 Birth: - [ root@chiji51 ~]# touch -r a.txt b.txt [root@chiji51 ~]# stat b.txt Access: 2017-05-12 00:00:00.000000000 +0800 Modify: 2019-05-12 20:09:21.341666942 +0800 Change: 2019-05-12 20:12:17.453677568 +0800 Birth: -
-t STAMP 把[[CC]YY]MMDDhhmm[.ss] instead of current time
这个与-d参数的不同是年份和秒钟可以省略[root@chiji51 ~]# stat b.txt Access: 1805-02-04 05:00:00.000000000 +0805 Modify: 1805-02-04 05:00:00.000000000 +0805 Change: 2019-05-12 20:21:01.117709167 +0800 [root@chiji51 ~]# touch -t "05020405" b.txt [root@chiji51 ~]# stat b.txt Access: 2019-05-02 04:05:00.000000000 +0800 Modify: 2019-05-02 04:05:00.000000000 +0800 Change: 2019-05-12 20:22:15.637713664 +0800
–time=WORD 改变文件的时间
WORD的值有 - ‘atime’, ‘access’, ‘use’
- ‘mtime’, ‘modify’
如果WORD等于a,则相当于运行 -a参数的命令[root@chiji51 ~]# touch --time=a b.txt [root@chiji51 ~]# stat b.txt Access: 2019-05-12 20:31:13.835746139 +0800 Modify: 2019-05-02 04:05:00.000000000 +0800 Change: 2019-05-12 20:31:13.835746139 +0800
如果WORD等于m,则相当于运行 -m参数的命令
[root@chiji51 ~]# touch --time=m b.txt [root@chiji51 ~]# stat b.txt Access: 2019-05-12 20:31:13.835746139 +0800 Modify: 2019-05-12 20:34:33.277758174 +0800 Change: 2019-05-12 20:34:33.277758174 +080
-
touch 命令的用法
2010-03-29 16:27:00名称:touch 使用权限:所有使用者使用方式: touch [-acfm] [-r reference-file] [--file=reference-file] [-t MMDDhhmm[[CC]YY][.ss]] [-d time] [--date=time] [--time={atime,access,use,mtime,modify}]名称:touch
使用权限:所有使用者
使用方式:
touch [-acfm]
[-r reference-file] [--file=reference-file]
[-t MMDDhhmm[[CC]YY][.ss]]
[-d time] [--date=time] [--time={atime,access,use,mtime,modify}]
[--no-create] [--help] [--version]
file1 [file2 ...]
说明:
touch 指令改变档案的时间记录。 ls -l 可以显示档案的时间记录。
参数:
a 改变档案的读取时间记录。
m 改变档案的修改时间记录。
c 假如目的档案不存在,不会建立新的档案。与 --no-create 的效果一样。
f 不使用,是为了与其他 unix 系统的相容性而保留。
r 使用参考档的时间记录,与 --file 的效果一样。
d 设定时间与日期,可以使用各种不同的格式。
t 设定档案的时间记录,格式与 date 指令相同。
--no-create 不会建立新档案。
--help 列出指令格式。
--version 列出版本讯息。
范例:
最简单的使用方式,将档案的时候记录改为现在的时间。若档案不存在,系统会建立一个新的档案。
touch file
touch file1 file2
将 file 的时间记录改为 5 月 6 日 18 点 3 分,公元两千年。时间的格式可以参考 date 指令,至少需输入 MMDDHHmm ,就是月日时与分。
touch -c -t 05061803 file
touch -c -t 050618032000 file
将 file 的时间记录改变成与 referencefile 一样。
touch -r referencefile file
将 file 的时间记录改成 5 月 6 日 18 点 3 分,公元两千年。时间可以使用 am, pm 或是 24 小时的格式,日期可以使用其他格式如 6 May 2000 。
touch -d "6:03pm" file
touch -d "05/06/2000" file
touch -d "6:03pm 05/06/2000" file -
linux中touch命令的常见用法
2014-12-03 20:00:39linux下touch命令的常见用法linux下touch命令常用作改变文件或目录时间
语 法:touch [-acfm][-d <日期时间>][-r <参考文件或目录>][-t <日期时间>][--help]
[--version][文件或目录...] 或 touch [-acfm][--help][--version][日期时间][文件或目录...]
简单的说就是可以把没有的文件给创建了,若一个文件已经存在又一次使用touch命令
则可以把时间修改为当前的时间,还可以任意的按照格式修改文件的时间为任意的时间等
可以一次创建多个文件:
touch file1 file2 file3 ...
创建了file1 file2 file3三个文件 ,写法可以是:
touch file{1,2,3} 效果和上面的相同。
-
Linux下touch命令的用法
2016-01-12 23:20:30Touch Command Options a, change the access time only -c, if the file does not exist, do not create it -d, update the access and modification times -m, change the modification time only -r, use ... -
source命令用法 export touch alias
2011-11-17 15:50:10source命令用法:source FileName作用:在当前bash环境下读取并执行FileName中的命令。注:该命令通常用命令“.”来替代。如:source .bash_rc 与 . .bash_rc 是等效的。注意:source命令与shell scripts的区别是,... -
技巧2——touch命令的所有用法你都得会
2019-05-23 18:09:55touch命令主要用于创建一个空文件,但它也可以更改unix和linux系统上现有文件的时间戳 这里所说的更改时间戳意味着更新文件和目录的访问以及修改时间 (1)使用touch建立一个空文件 (2)使用touch批量创建... -
linux中新建文件命令touch用法详解
2011-06-13 15:12:41linux中的touch命令一般用来修改文件的时间,或者新建一个不存在的文件. 语法如下: touch [-acm][-r ref_file(参照文件)|-t time(时间值)] file(文件名) 例子: touch file1.txt 更新file1.txt的存取和修改... -
Linux命令用法总结
2021-01-09 07:57:06LinuxLinux基本命令的基本使用常用Linux命令用法不常用Linux命令用法查看或配置网卡信息ifconfig:ping: Linux基本命令的基本使用 命令 作用 ls 查看当前文件下的内容 pwd 查看当前所在文件夹 cd【目录名... -
Touch命令
2019-07-01 20:10:54最常用用法:touch fileA 如果fileA存在,使用touch指令可更改这个文件或目录的日期时间,包括存取时间和更改时间; 如果fileA不存在,touch指令会在当前目录下新建一个空白文件fileA FR:徐海涛(hunk Xu) QQ技术... -
linux命令-touch命令
2018-06-24 18:41:54touch命令 一、简介 touch命令将每个文件的访问时间和修改时间改为当前时间。 二、用法 touch [选项] ... 文件 ... 三、选项 -a : 只更改访问时间 -c, --no-create : 不创建任何文件 -d, --date=字符...