当前位置:首页 » 操作系统 » touchlinux

touchlinux

发布时间: 2022-09-02 23:01:38

linux的touch命令怎么用

linux的touch命令不常用,一般在使用make的时候可能会用到,用来修改文件时间戳,或者新建一个不存在的文件。
1|0命令格式:
touch [选项]... 文件...

2|0命令参数:
-a 或--time=atime或--time=access或--time=use 只更改存取时间。-c 或--no-create 不建立任何文档。-d 使用指定的日期时间,而非现在的时间。-f 此参数将忽略不予处理,仅负责解决BSD版本touch指令的兼容性问题。-m 或--time=mtime或--time=modify 只更改变动时间。-r 把指定文档或目录的日期时间,统统设成和参考文档或目录的日期时间相同。-t 使用指定的日期时间,而非现在的时间。《Linux就该这么学》 一起学习linux
3|0命令功能:
touch命令参数可更改文档或目录的日期时间,包括存取时间和更改时间。
4|0使用范例:
实例一: 创建不存在的文件
命令:
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

实例二: 更新log.log的时间和log2012.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

实例三: 设定文件的时间戳
命令: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

Ⅱ linux命令的touch命令意思

linux中的touch命令一般用来修改文件的时间,或者新建一个不存在的文件.
-a                    只更改访问时间

Ⅲ linux常用命令的“cat”和“touch”有什么区别

名称:cat
使用权限:所有使用者
使用方式:cat [-AbeEnstTuv] [--help] [--version] fileName
说明:把档案串连接后传到基本输出(萤幕或加 > fileName 到另一个档案)
参数:
-n 或 --number 由 1 开始对所有输出的行数编号
-b 或 --number-nonblank 和 -n 相似,只不过对于空白行不编号
-s 或 --squeeze-blank 当遇到有连续两行以上的空白行,就代换为一行的空白行
-v 或 --show-nonprinting

范例:
cat -n textfile1 > textfile2 把 textfile1 的档案内容加上行号后输入 textfile2 这个档案里
cat -b textfile1 textfile2 >> textfile3 把 textfile1 和 textfile2 的档案内容加上行号(空白行不加)之后将内容附加到 textfile3
名称: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命令 一次建立多个文件例如想建1.txt 2.txt……9.txt

必须用shell吧?,你这要求很变态啊,囧了。
我去试试再说吧
额,另外,touch命令不支持正则表达式
额,如下,写一个shell脚本
#!/bin/bash
for filename in $( seq 1 10 )
do
touch ${filename}.txt
done
然后运行之,即可

Ⅳ 请教linux下的touch命令建立文件

touch命令用来修改文件的访问时间、修改时间。如果没有指定时间,则将文件时间属性改为当前时间。当指定文件不存在,则touch命令变为创建该文件。
语法:
touch [-acm] [-d STRING-time] [-r reference-file] [-t [[CC]YY]MMDDhhmm[.ss]]

选项介绍:
-a: 只修改访问时间;
-c: 如果指定文件不存在,则不创建文件;
-d STRING-time: 用字符串格式的时间来指定时间属性的修改值;
-m: 只修改指定文件的修改时间;
-r refernce-file: 将指定文件的时间属性改为与reference-file时间属性相同的值;
-t [[CC]YY]MMDDhhmm[.ss]: 用[[CC]YY]MMDDhhmm[.ss]这种时间格式来指定时间属性的修改值;
使用范例:
实例一:创建不存在的文件
命令:
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

实例二:更新log.log的时间和log2012.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

实例三:设定文件的时间戳
命令:
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日的时间是错误的。

Ⅵ linux为什么要用touch创建文件

vi需要键盘输入,也就是和人互动,这就无法实现自动化脚本运行
次要原因这个操作耗时较长,往快了说估计也要1秒钟
如果我有个任务,要创建100万个文件,那要到猴年马月了

Ⅶ linux命令中touch {1..100}中的..是什么意思

touch {1..100} 中, touch 是更新文件时间戳命令,无文件则创建。

(假如你的shell环境为bash)

{1..100}bash花括号展开表达式

1 表示起始的数字

.. 表示连续的意思

100表示终止数字的意思,也包括这个数字

步进为1, 左右闭合

命令执行时,bash会自动展开touch {1..100} 就变成了 touch 1 2 3 4 5 6 7 此处省略 100

截图是bash的源码中处理花括号(curly braces)的扫描代码。文件为: braces.c

并且这个花括号表达式是在3.0以上bash中使用。

Ⅷ Linux里面touch -a命令作用是什么

touch -a是改变文件读取时间的

Ⅸ Linux中touch的作用。

1、使用touch命令创建一个单个文件test,执行touchtest,如图所示:

热点内容
java程序反编译 发布:2025-05-14 02:18:46 浏览:456
蛤蟆编程 发布:2025-05-14 02:17:12 浏览:641
解压缩文件后缀 发布:2025-05-14 02:14:07 浏览:303
阅章娱乐系统清理数据密码是多少 发布:2025-05-14 02:09:10 浏览:972
米家的密码锁初始密码是多少 发布:2025-05-14 01:58:51 浏览:36
存储空间和内存的区别 发布:2025-05-14 01:57:20 浏览:951
市里煤炭资源配置是什么意思 发布:2025-05-14 01:52:23 浏览:307
c删除一行数据库 发布:2025-05-14 01:50:53 浏览:74
sql辅助 发布:2025-05-14 01:50:46 浏览:324
为什么要限制上传速度 发布:2025-05-14 01:45:07 浏览:620