用途

touch命令参数可更改文档或目录的日期时间,包括存取时间和更改时间。

全称

touch全称即为touch

参数

-a   :或--time=atime或--time=access或--time=use  只更改存取时间。

-c   :或--no-create  不建立任何文档。

-d   :使用指定的日期时间,而非现在的时间。

-f  :此参数将忽略不予处理,仅负责解决BSD版本touch指令的兼容性问题。

-m  : 或--time=mtime或--time=modify  只更改变动时间。

-r  :把指定文档或目录的日期时间,统统设成和参考文档或目录的日期时间相同。

-t  :使用指定的日期时间,而非现在的时间。

案例

案例一:创建不存在的文件

[root@bigdata /]# touch 1.txt 2.txt

[root@bigdata /]# ll *.txt


总用量 408

-rw-r--r--.   1 root root      0 8月  15 16:48 1.txt

-rw-r--r--.   1 root root      0 8月  15 16:48 2.txt

案例二:更新时间戳

[root@bigdata /]# ll 1.txt a.txt

-rw-r--r--. 1 root root   0 8月  15 16:48 1.txt

-rw-r--r--. 1 root root 680 8月  15 15:01 a.txt

[root@bigdata /]# touch -r 1.txt a.txt

[root@bigdata /]# ll 1.txt a.txt


-rw-r--r--. 1 root root   0 8月  15 16:48 1.txt

-rw-r--r--. 1 root root 680 8月  15 16:48 a.txt

案例三:设定文件的时间戳

[root@bigdata /]# touch -t 200012311830.40 1.txt

[root@bigdata /]# ll 1.txt

-rw-r--r--. 1 root root 0 12月 31 2000 1.txt

案例四:修改文件2.txt的时间为2天前

[root@bigdata /]# ll 2.txt

-rw-r--r--. 1 root root 0 8月  15 16:48 2.txt

[root@bigdata /]# touch -d "2 days ago" 2.txt

[root@bigdata /]# ll 2.txt


-rw-r--r--. 1 root root 0 8月  13 16:56 2.txt

【Linux】touch命令的更多相关文章

  1. Linux touch命令详解

    Linux touch命令 Linux touch命令用于修改文件或者目录的时间属性,包括存取时间和更改时间.若文件不存在,系统会建立一个新的文件. 用法: touch [-acfm][-d<日 ...

  2. Linux Touch命令的8种使用技巧

    Linux touch命令不仅可以用于在Linux上创建空文件. 您可以使用它来更改现有文件的时间戳,包括其访问权限和修改时间. 本文介绍了8种可以通过Linux终端使用touch命令的方案. 我们在 ...

  3. Linux Touch命令的8种常见使用方法

    Linux touch命令不仅可以用于在Linux上创建空文件. 您可以使用它来更改现有文件的时间戳,包括其访问权限和修改时间. 本文介绍了8种可以通过Linux终端使用touch命令的方案. 我们在 ...

  4. Linux -- touch 命令

    在Linux中,每个文件都关联一个时间戳,并且每个文件搜会存储最近一次访问的时间.最近一次修改的时间和最近一次变更的时间等信息.所以,无论何时我们创建一个新文件,访问或者修改一个已经存在的文件,文件的 ...

  5. Linux touch命令

    touch命令不常用,一般用于更改文件时间戳,或创建一个空文件 命令选项 -a:只更改访问时间 -c:--no-create 不创建任何文件 -d:--date=字符串 使用指定字符串表示时间而非当前 ...

  6. 今天给各位介绍Linux touch命令详述

    触摸命令 touch命令有两个功能:一个是将现有文件的时间戳更新为系统的当前时间(默认模式),它们的数据将保持不变;第二个是创建一个新的空文件. 语法 触摸(可选) 最常见的用法:touch file ...

  7. linux touch命令 创建文件

    touch 创建文件,用法,touch test.txt,如果文件存在,则表示修改当前文件时间 [root@MongoDB ~]# touch /data/text.txt [root@MongoDB ...

  8. Linux上的10个Touch命令实例

    Linux Touch 命令 Touch命令可以用来修改文件访问或修改的时间戳.实际上,它更常仅仅用于快速的创建一个空白文件. 这篇文章展示了一些非常简单和快速的实例,使用Touch命令来修改时间戳和 ...

  9. C实现Linux之touch命令

    Linux 的 touch 命令用来修改文件时间戳,或者新建一个不存在的文件,使用方式如下: touch [-acm][-r ref_file(参照文件)|-t time(时间值)] file(文件名 ...

  10. Linux中8个有用的touch命令

    在Linux中,每个文件都有时间戳,并且每个文件都存储上次访问时间,上次修改时间,上次改变时间的信息.因此,无论什么时候我们创建新的文件,访问或者修改一个存在的文件,那个文件的时间戳会自动被更改. 在 ...

随机推荐

  1. bzoj 1776

    收获: 树上直径一定包含深度最深的点. 然后O(nlogn) 暴力. /************************************************************** P ...

  2. Loj10170骑士

    试题描述 在 n×n(1≤n≤10)的棋盘上放 k(0≤k≤n)个国王(可攻击相邻的8个格子),求使它们无法互相攻击的方案总数. 输入 输入有多组方案,每组数据只有一行为两个整数n和k. 输出 每组数 ...

  3. Linux下Apache2.2和PHP5的安装配置

    Linux下Apache2.2和PHP5的安装配置 环境介绍 我安装使用的Linux版本为CentOS6.5最精简版,Apache为2.2.29,PHP版本为5.4.28. 系统安装 首先安装Cent ...

  4. Educational Codeforces Round 11 C. Hard Process 二分

    C. Hard Process 题目连接: http://www.codeforces.com/contest/660/problem/C Description You are given an a ...

  5. UESTC 2015dp专题 j 男神的约会 bfs

    男神的约会 Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://acm.uestc.edu.cn/#/contest/show/65 Descri ...

  6. Cocoapods报错Unable to satisfy the following requirements

    很多时候我们都会去gitHub上down别人的源码去研究,如果别人的项目用pod集成了,当我们下载好后不外乎cd到项目根目录pod install一下,集成项目所需的库类.今天在我pod instal ...

  7. Transistor latch improves on/off circuitry

    Figure 1 shows an example of on/off circuitry commonly used in battery-operated devices. The p-chann ...

  8. 【转】2012年6月26 – 盛大PHP工程师最新面试题

    无笔试. 口试:(前半部分平淡无奇,没什么太难的问题,都是求职岗位基本要会的东西,局限于php.下面是真正进入状态的题.) 谈谈观察者模式是什么?主要应用. 答:类似会有一些server对象时刻侦听某 ...

  9. 关于DIV多层嵌套的margin-top的BUG

    今天在做登录页面的时候发现个margin-top的bug ; 初始代码如下: html: <div class="logo"></div> <div ...

  10. JQuery 关于位置的计算(重要)

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...