linux 中使用cat来创建文件

发布时间 2023-06-22 20:56:03作者: 小鲨鱼2018

 

001、cat > file

[root@PC1 test01]# ls
[root@PC1 test01]# cat > a.txt
a b c d                     ## 利用键盘输出内容
0 1 2 3                     ## 利用ctrl + D 进行终止      
[root@PC1 test01]# ls
a.txt
[root@PC1 test01]# cat a.txt    ## 查看
a b c d
0 1 2 3

 

002、cat > file << 终止符号

[root@PC1 test01]# ls
[root@PC1 test01]# cat > a.txt << EOF      ## EOF为终止符号
> a b c d
> 0 1 2 3              ## 利用键盘输入
> EOF                  ## 结束符号
[root@PC1 test01]# ls
a.txt
[root@PC1 test01]# cat a.txt      ## 查看文件
a b c d
0 1 2 3