linux的touch命令不常用,一般在使用make的时候可能会用到,用来修改文件时间戳,或者新建一个不存在的文件。
----------------------------------------------------------------------------------------
1.命令格式:
touch [选项]... 文件...
2.命令参数:
-a 或--time=atime或--time=access或--time=use 只更改存取时间。
-c 或--no-create 不建立任何文档。
-d 使用指定的日期时间,而非现在的时间。
-f 此参数将忽略不予处理,仅负责解决BSD版本touch指令的兼容性问题。
-m 或--time=mtime或--time=modify 只更改变动时间。
-r 把指定文档或目录的日期时间,统统设成和参考文档或目录的日期时间相同。
-t 使用指定的日期时间,而非现在的时间。
3.命令功能:
touch命令参数可更改文档或目录的日期时间,包括存取时间和更改时间。
4.使用范例:
-------------------------------------------------------------------------------------
实例1:创建不存在的文件
命令:
touch log2012.log log2013.log
输出:
[root@localhost test]# touch log2012.log log2013.log
[root@localhost test]# ll
-rw-r--r-- 1 root root 0 10-28 16:01 log2012.log
-rw-r--r-- 1 root root 0 10-28 16:01 log2013.log
如果log2014.log不存在,则不创建文件
[root@localhost test]# touch -c log2014.log
[root@localhost test]# ll
-rw-r--r-- 1 root root 0 10-28 16:01 log2012.log
-rw-r--r-- 1 root root 0 10-28 16:01 log2013.log
实例2:更新 log2012.log 时间戳,让它跟 log.log 相同
命令:
touch -r log.log log2012.log
输出:
[root@localhost test]# ll
-rw-r--r-- 1 root root 0 10-28 16:01 log2012.log
-rw-r--r-- 1 root root 0 10-28 16:01 log2013.log
-rw-r--r-- 1 root root 0 10-28 14:48 log.log
[root@localhost test]# touch -r log.log log2012.log
[root@localhost test]# ll
-rw-r--r-- 1 root root 0 10-28 14:48 log2012.log
-rw-r--r-- 1 root root 0 10-28 16:01 log2013.log
-rw-r--r-- 1 root root 0 10-28 14:48 log.log
实例3:设定文件的时间戳
命令:
touch -t 201211142234.50 log.log
输出:
[root@localhost test]# ll
-rw-r--r-- 1 root root 0 10-28 14:48 log2012.log
-rw-r--r-- 1 root root 0 10-28 16:01 log2013.log
-rw-r--r-- 1 root root 0 10-28 14:48 log.log
[root@localhost test]# touch -t 201211142234.50 log.log
[root@localhost test]# ll
-rw-r--r-- 1 root root 0 10-28 14:48 log2012.log
-rw-r--r-- 1 root root 0 10-28 16:01 log2013.log
-rw-r--r-- 1 root root 0 2012-11-14 log.log
说明:
-t time 使用指定的时间值 time 作为指定文件相应时间戳记的新值.此处的 time规定为如下形式的十进制数:
[[CC]YY]MMDDhhmm[.SS]
这里,CC为年数中的前两位,即”世纪数”;YY为年数的后两位,即某世纪中的年数.如果不给出CC的值,则touch 将把年数CCYY限定在1969--2068之内.MM为月数,DD为天将把年数CCYY限定在1969--2068之内.MM为月数,DD为天数,hh 为小时数(几点),mm为分钟数,SS为秒数.此处秒的设定范围是0--61,这样可以处理闰秒.这些数字组成的时间是环境变量TZ指定的时区中的一个时 间.由于系统的限制,早于1970年1月1日的时间是错误的。
相关推荐
(一)2天学完linux视频教程 F—day01(第一天) linux学习视频day01:1-linux操作系统介绍...linux学习视频day01:7-touch命令.mp4 linux学习视频day01:8-rm命令.mp4 linux学习视频day01:9-命令格式介绍.mp4 L-day02(第二天)
该文档主要针对于Linux常用命令进行汇总与简化,从而让您易学且轻松,该文档虽然不大...IP配置,挂载方法以及ssh免密登录配置等等,希望能帮助那些在学习linux命令而又苦恼不知从哪开始学习的朋友们,真心对你们有用!
Linux命令格式 命令 [-选项] [参数] ctrl+l清屏 1.2目录处理命令 1. ls----显示目录文件 组里每个成员都享有这个组的权限 -d 查看目录属性 显示目录本身,而不显示目录下的数据 2. mkdir----...
每个命令都有其特定的功能和使用场景,对于初学者来说,理解和掌握这些命令是学习Linux操作系统的关键。本资源适用于所有初学者以及对Linux系统感兴趣的人。无论您是计算机专业的学生还是对Linux感兴趣的普通用户,...
Linux命令 学习Linux的第一步:当然是从入手了。 help-关键词: help , whatis , info , which , whereis , man cd , ls , pwd , mkdir , rmdir , tree , touch , ln , rename , stat , file , ...
Linux命令大全搜索工具,内容包含Linux命令手册、详解、学习、搜集。 Linux命令分类 这里存放Linux 命令大全并不全,你可以通过linux-command来搜索,它是把 command 目录里面搜集的...
01. 学习 Linux 终端命令的原因 02. 常用 Linux 命令的基本使用 03. 自动补全 Linux 终端命令格式 01. 终端命令格式 02. 查阅命令帮助信息(知道) 2.1 --help 2.2 man 文件和目录常用命令 目标 01. 查看...
Linux命令的格式(command为必填,其余为选填):command(命令) + [-options](选项) + [parameter1](参数) … 前面有“-”代表选项,无代表参数(参数与选项无前后关系) 1.ls :显示当前路径(当前文件夹)下的...
在本篇文章里小编给各位整理的是关于linux touch命令的相关知识点内容,有需要的朋友们可以参考学习下。
自己学习《APUE》时写的linux下一些命令(大概40个左右)实现,仅当学习使用,这些命令包括cat cp echo head ls paste rmdir tail umask who chattr cut expand join mkdir pwd sed tee uniq chgrp date find last ...
此文档格式为ppt格式,支持下载,主要从linux常用的基础命令入手,包含cat、more、ps、touch、rmdir等命令,帮助初学者来学习linux。
linux下大部分常用命令源码,偶正要开始学习-_- base64.c basename.c c99-to-c89.diff cat.c chcon.c chgrp.c chmod.c chown.c chown-core.c chown-core.h chroot.c cksum.c comm.c copy.c cp.c cp-hash.c csplit.c ...
linux学习笔记之常用命令(一)——文件处理命令命令格式与文件处理命令ls命令命令格式与文件处理命令ls命令(类似windows的查看文件属性)目录处理命令目录处理命令之mkdir命令(类似windows的创建文件夹)目录处理...
文章目录Linux常用命令一1、 ls-查看文件信息2、clear-清屏3、cd-切换目录4、 pwd-显示所在路径5、 mkdir-创建目录6、rm-删除内容7、cp-copy8、 创建文件: touch9、 mv-重命名和移动 Linux常用命令一 如果对基础有...
Linux常用命令总结,详解。包含:pwd、cd、grep、touch、cat、rm、vi等命令。 学习掌握后,定能让你日常使用Linux中得心应手。且面试时也不怕再被问到了。
以下是部分列举Linux中常用的命令及其用法: 1. ls:用于列出指定目录中的文件和目录,常用选项有-l(显示详细信息)、-a(显示所有文件和目录,包括隐藏文件和目录)。 2. cd:用于切换目录,常用的操作有cd .....
⼀、 Python 学习的四个阶段 第⼀阶段 该阶段⾸先通过介绍不同领域的三种操作系统,操作系统的发展简史以及 Linux 系统的⽂件⽬录结构让⼤家对 Linux 系统有⼀个简单的认识, 同时知道为 什么要学习 Linux 命令。...
Hadoop运行在Linux系统上,因此,需要学习实践一些常用的Linux命令。本实验旨在熟悉常用的Linux操作,为顺利开展后续其他实验奠定基础。 二、实验环境 Windows 10 VMware Workstation Pro虚拟机 Hadoop环境 Jdk1.8 ...
一:配置环境变量,实现执行history...基本命令语法格式可以通过man 命令来进行查询,这里只是通过date这个命令进行简单示范,在学习linux知识,融合帮助文档进行学习很多时候都可以达到事半功倍的效果! 举例: man
linux 相关学习记录: ls -l 获得当前目录下的所有文件 2、cd 获得指定文件目录位置 3、pwd 获得当前目录位置 4、touch 在指定目录下生成一个空文件 5、cp 将某个文件复制到目标文件 mv 改变文件名或移动文件 rm ...