touch 命令

touch命令
==========================================

Linux touch命令用于修改文件或者目录的时间属性,包括存取时间和更改时间。

若文件不存在,系统会建立一个新的文件。
ls -l 可以显示档案的时间记录。

[root@aminglinux ~]# stat 1.txt

文件:"1.txt" 大小:52 块:8 IO 块:4096 普通文件

设备:803h/2051d Inode:33574998 硬链接:1

权限:(0674/-rw-rwxr--) Uid:( 0/ root) Gid:( 0/ root)

最近访问:2018-06-10 22:54:03.253312759 +0800

最近更改:2018-06-10 22:53:01.260640875 +0800

最近改动:2018-06-10 22:53:01.260640875 +0800

创建时间:-

[root@aminglinux ~]# touch 1.txt[root@aminglinux ~]# stat 1.txt

文件:"1.txt" 大小:52 块:8 IO 块:4096 普通文件

设备:803h/2051d Inode:33574998 硬链接:1

权限:(0674/-rw-rwxr--) Uid:( 0/ root) Gid:( 0/ root)

最近访问:2018-06-10 22:54:56.698892008 +0800最

近更改:2018-06-10 22:54:56.698892008 +0800

最近改动:2018-06-10 22:54:56.698892008 +0800

创建时间:-

[root@aminglinux ~]# ls1.txt anaconda-ks.cfg dir10         //目录中不存在2.txt

[root@aminglinux ~]# touch 2.txt

[root@aminglinux ~]# ls

1.txt 2.txt anaconda-ks.cfg dir10              //在目录中建立一个新的文件2.txt

扩展内容:

  # touch file1 //无则创建,有则修改时间
# touch file3 file4
# touch /home/file10
# touch /home/file{5,6}
# touch /home/{zhuzhu,gougou}
# touch file{11..20}
# touch file{a..z}
# touch sambo{a,b,c} //{}集合,等价 touch samboa sambob samboc 

示例:
[root@aminglinux ~]# ls
1.txt 2.txt anaconda-ks.cfg dir10
[root@aminglinux ~]# touch file1
[root@aminglinux ~]# ls
1.txt 2.txt anaconda-ks.cfg dir10 file1
[root@aminglinux ~]# touch file3 file4
[root@aminglinux ~]# ls
1.txt 2.txt anaconda-ks.cfg dir10 file1 file3 file4
[root@aminglinux ~]# touch /root/file10
[root@aminglinux ~]# ls
1.txt 2.txt anaconda-ks.cfg dir10 file1 file10 file3 file4
[root@aminglinux ~]# touch /root/file{5,6}
[root@aminglinux ~]# ls
1.txt 2.txt anaconda-ks.cfg dir10 file1 file10 file3 file4 file5 file6
[root@aminglinux ~]# touch /root/{file7,3.txt,4.txt}
[root@aminglinux ~]# ls
1.txt 2.txt 3.txt 4.txt anaconda-ks.cfg dir10 file1 file10 file3 file4 file5 file6 file7
[root@aminglinux ~]# touch file{11..20}
[root@aminglinux ~]# ls
1.txt 3.txt anaconda-ks.cfg file1 file11 file13 file15 file17 file19 file3 file5 file7
2.txt 4.txt dir10 file10 file12 file14 file16 file18 file20 file4 file6
[root@aminglinux ~]# touch file{a..z}
[root@aminglinux ~]# ls
1.txt anaconda-ks.cfg file11 file15 file19 file5 fileb filef filej filen filer filev filez
2.txt dir10 file12 file16 file20 file6 filec fileg filek fileo files filew
3.txt file1 file13 file17 file3 file7 filed fileh filel filep filet filex
4.txt file10 file14 file18 file4 filea filee filei filem fileq fileu filey
[root@aminglinux ~]# touch sambo{a,b,c,d}
[root@aminglinux ~]# ls
1.txt dir10 file13 file18 file5 filec fileh filem filer filew sambob
2.txt file1 file14 file19 file6 filed filei filen files filex samboc
3.txt file10 file15 file20 file7 filee filej fileo filet filey sambod
4.txt file11 file16 file3 filea filef filek filep fileu filez
anaconda-ks.cfg file12 file17 file4 fileb fileg filel fileq filev samboa

posted @ 2018-06-13 17:19  SamboLee  阅读(212)  评论(0编辑  收藏  举报