示例:
[root@localhost ~]# cat /etc/profile 注:检查/etc/目录下的profile文件内容;
[root@localhost ~]# cat -b /etc/profile 注:检查/etc/目录下的profile内容,而且对非空白行进行编号,行号从1开端;
[root@localhost ~]# cat -n /etc/profile 注:对/etc目录中的profile的一切的行(包含空白行)进行编号输出显现;
[root@localhost ~]# cat -E /etc/profile 注:检查/etc/下的profile内容,而且在每行的结尾处附加$符号;
cat 加参数-n 和nl东西差不多,文件内容输出的一同,都会在每行前面加上行号;
[root@localhost ~]# cat -n /etc/profile
[root@localhost ~]# nl /etc/profile
cat 能够一同显现多个文件的内容,比方咱们能够在一个cat指令上一同显现两个文件的内容;
[root@localhost ~]# cat /etc/fstab /etc/profile
cat 关于内容极大的文件来说,能够经过管道|传送到more 东西,然后一页一页的检查;
[root@localhost ~]# cat /etc/fstab /etc/profile | more
1.2 cat 的create、衔接文件功用实例;
cat 有create文件的功用,create文件后,要以EOF或STOP完毕;
[root@localhost ~]# cat > linuxtest.c.txt << EOF 注:create linuxtest.c.txt文件;
> 我来测验 cat create文件,而且为文件输入内容; 注:这是为linuxtest.c.txt文件输入内容;
> JonesJones测验; 注:这是为linuxtest.c.txt文件输入内容;
> EOF 注:退出修改状况;
[root@localhost ~]# cat linuxtest.c.txt 注:咱们检查一下linuxtest.c.txt文件的内容;
[root@localhost ~]# cat >> linuxtest.txt << EOF 注:咱们向linuxtest.txt文件追加内容;
> 我来测验cat向文档追加内容的功用; 注:这是追回的内容
> OK?
> OK~
> Jones 递上
> EOF 注:以EOF退出
[root@localhost ~]# cat linuxtest.txt 注:检查文件内容,看能否追回成功。
[root@localhost ~]# cat /etc/profile 注:检查/etc/目录下的profile文件内容;
[root@localhost ~]# cat -b /etc/profile 注:检查/etc/目录下的profile内容,而且对非空白行进行编号,行号从1开端;
[root@localhost ~]# cat -n /etc/profile 注:对/etc目录中的profile的一切的行(包含空白行)进行编号输出显现;
[root@localhost ~]# cat -E /etc/profile 注:检查/etc/下的profile内容,而且在每行的结尾处附加$符号;
cat 加参数-n 和nl东西差不多,文件内容输出的一同,都会在每行前面加上行号;
[root@localhost ~]# cat -n /etc/profile
[root@localhost ~]# nl /etc/profile
cat 能够一同显现多个文件的内容,比方咱们能够在一个cat指令上一同显现两个文件的内容;
[root@localhost ~]# cat /etc/fstab /etc/profile
cat 关于内容极大的文件来说,能够经过管道|传送到more 东西,然后一页一页的检查;
[root@localhost ~]# cat /etc/fstab /etc/profile | more
1.2 cat 的create、衔接文件功用实例;
cat 有create文件的功用,create文件后,要以EOF或STOP完毕;
[root@localhost ~]# cat > linuxtest.c.txt << EOF 注:create linuxtest.c.txt文件;
> 我来测验 cat create文件,而且为文件输入内容; 注:这是为linuxtest.c.txt文件输入内容;
> JonesJones测验; 注:这是为linuxtest.c.txt文件输入内容;
> EOF 注:退出修改状况;
[root@localhost ~]# cat linuxtest.c.txt 注:咱们检查一下linuxtest.c.txt文件的内容;
[root@localhost ~]# cat >> linuxtest.txt << EOF 注:咱们向linuxtest.txt文件追加内容;
> 我来测验cat向文档追加内容的功用; 注:这是追回的内容
> OK?
> OK~
> Jones 递上
> EOF 注:以EOF退出
[root@localhost ~]# cat linuxtest.txt 注:检查文件内容,看能否追回成功。