此链接 通往 Linux 命令大全手册,点一下不会吃亏不会上当!说不定还会涨知识:
touch —— 创建文件:
root@zhengzelin:~\# type touch
touch is /usr/bin/touch
touch 是一个外部命令!
touch 命令 有两个作用:
①、创建新的空文件;
②、更改已经存在文件的时间签为当前系统时间
1、创建新文件:
root@zhengzelin:~\# touch a.txt
root@zhengzelin:~\# ll | grep a.txt
-rw-r--r-- 1 root root 0 Apr 8 21:11 a.txt
2、更改已存在文件的时间签(时间已经过去两分钟)
root@zhengzelin:~\# touch a.txt (此时 a.txt 文件已经存在!)
root@zhengzelin:~# ll | grep a.txt
-rw-r--r-- 1 root root 0 Apr 8 21:13 a.txt
# 时间签已经发生变化!
创建多个文件:
root@zhengzelin:~\# touch a.txt b.txt c.txt
root@zhengzelin:~\# ls *.txt
a.txt b.txt c.txt
root@zhengzelin:~\# touch {1..3}.txt
root@zhengzelin:~\# ls *.txt
1.txt 2.txt 3.txt a.txt b.txt c.txt
touch 命令的常用选项:
-d : 使用指定的时间,并非现在的时间!
-f : 此参数将忽略不予处理,仅负责解决BSD版本touch指令的兼容性问题;
-t : 使用指定的时间,并非现在的时间!
注意:
touch 所创建的文件 是在当前目录下创建的
要在其他目录下创建文件,直接 touch /目录/filename 即可!