每日一命令(10)cat (concatenate files and print on the standard output)
2016-06-16 10:04
726 查看
cat concatenate files and print on the standard output 拼接文件和输出文件
man cat 查看命令文档cat 查看文件
cat > file 创建文件,但是不能编辑已经存在的文件
cat options file
-A, --show-all 等价于 -vET -b, --number-nonblank 对非空输出行编号 -e 等价于 -vE -E, --show-ends 在每行结束处显示 $ -n, --number 对输出的所有行编号 -s, --squeeze-blank 不输出多行空行 -t 与 -vT 等价 -T, --show-tabs 将跳 字符显示为 ^I -u (被忽略) -v, --show-nonprinting 使用 ^ 和 M- 引用,除了 LFD 和 TAB 之外 --help 显示此帮助信息并离开
cat file1.txt 输出文件内容
root@nginx02 ~ # ll total 56 -rw-------. 1 root root 1073 May 26 22:40 anaconda-ks.cfg -rw-r--r--. 1 root root 51 Jun 15 07:19 file1.txt -rw-r--r--. 1 root root 53 Jun 15 07:22 file2.txt -rw-r--r--. 1 root root 51 Jun 15 07:19 file3.txt -rw-r--r--. 1 root root 18 Jun 15 07:18 file4.txt -rw-r--r--. 1 root root 22179 May 26 22:40 install.log -rw-r--r--. 1 root root 5890 May 26 22:38 install.log.syslog root@nginx02 ~ # cat file1.txt 123123 asdfasfdsa sdfsfsd sdfsfsd sdfsdfds werqda
cat -bn -b 对空白行不编号,-n编号
root@nginx02 ~ # cat -b file2.txt 1 123123 2 asdfasfdsa 3 sdfsfsd 4 sdfsfsd 5 sdfsdfds 6 werqda root@nginx02 ~ # cat -n file2.txt 1 123123 2 asdfasfdsa 3 4 sdfsfsd 5 6 sdfsfsd 7 8 sdfsdfds 9 werqda
cat file1.txt file2.txt > file5.txt 拼接文件
root@nginx02 ~ # cat file1.txt file2.txt > file5.txt root@nginx02 ~ # ll total 60 -rw-------. 1 root root 1073 May 26 22:40 anaconda-ks.cfg -rw-r--r--. 1 root root 51 Jun 15 07:19 file1.txt -rw-r--r--. 1 root root 53 Jun 15 07:22 file2.txt -rw-r--r--. 1 root root 51 Jun 15 07:19 file3.txt -rw-r--r--. 1 root root 18 Jun 15 07:18 file4.txt -rw-r--r--. 1 root root 104 Jun 15 07:27 file5.txt -rw-r--r--. 1 root root 22179 May 26 22:40 install.log -rw-r--r--. 1 root root 5890 May 26 22:38 install.log.syslog root@nginx02 ~ # cat file5.txt 123123 asdfasfdsa sdfsfsd sdfsfsd sdfsdfds werqda 123123 asdfasfdsa sdfsfsd sdfsfsd sdfsdfds werqda
cat -s file2.txt 如果有多行空白,只显示一行空白
root@nginx02 ~ # cat -n file2.txt 1 123123 2 asdfasfdsa 3 4 sdfsfsd 5 6 sdfsfsd 7 8 sdfsdfds 9 werqda 10 11 12 root@nginx02 ~ # vat -ns file2.txt -bash: vat: command not found root@nginx02 ~ # cat -ns file2.txt 1 123123 2 asdfasfdsa 3 4 sdfsfsd 5 6 sdfsfsd 7 8 sdfsdfds 9 werqda 10 root@nginx02 ~ # cat -n file2.txt 1 123123 2 asdfasfdsa 3 4 5 6 sdfsfsd 7 8 sdfsfsd 9 10 sdfsdfds 11 werqda 12 13 14 root@nginx02 ~ # cat -sn file2.txt 1 123123 2 asdfasfdsa 3 4 sdfsfsd 5 6 sdfsfsd 7 8 sdfsdfds 9 werqda 10
cat > 创建文件 ctrl+c 保存
root@nginx02 ~ # ll total 60 -rw-------. 1 root root 1073 May 26 22:40 anaconda-ks.cfg -rw-r--r--. 1 root root 0 Jun 15 07:36 EOF -rw-r--r--. 1 root root 51 Jun 15 07:19 file1.txt -rw-r--r--. 1 root root 28 Jun 15 07:36 file2.txt -rw-r--r--. 1 root root 51 Jun 15 07:19 file3.txt -rw-r--r--. 1 root root 18 Jun 15 07:18 file4.txt -rw-r--r--. 1 root root 104 Jun 15 07:27 file5.txt -rw-r--r--. 1 root root 22179 May 26 22:40 install.log -rw-r--r--. 1 root root 5890 May 26 22:38 install.log.syslog root@nginx02 ~ # cat > file6.txt ^C root@nginx02 ~ # ll total 60 -rw-------. 1 root root 1073 May 26 22:40 anaconda-ks.cfg -rw-r--r--. 1 root root 0 Jun 15 07:36 EOF -rw-r--r--. 1 root root 51 Jun 15 07:19 file1.txt -rw-r--r--. 1 root root 28 Jun 15 07:36 file2.txt -rw-r--r--. 1 root root 51 Jun 15 07:19 file3.txt -rw-r--r--. 1 root root 18 Jun 15 07:18 file4.txt -rw-r--r--. 1 root root 104 Jun 15 07:27 file5.txt -rw-r--r--. 1 root root 0 Jun 15 07:40 file6.txt -rw-r--r--. 1 root root 22179 May 26 22:40 install.log -rw-r--r--. 1 root root 5890 May 26 22:38 install.log.syslog
cat > file6.txt << EOF ….. EOF 创建文件并且输入文件内容 内容的开始和结束必须的一模一样,顺便什么名字都可以
root@nginx02 ~ # ll total 60 -rw-------. 1 root root 1073 May 26 22:40 anaconda-ks.cfg -rw-r--r--. 1 root root 0 Jun 15 07:36 EOF -rw-r--r--. 1 root root 51 Jun 15 07:19 file1.txt -rw-r--r--. 1 root root 28 Jun 15 07:36 file2.txt -rw-r--r--. 1 root root 51 Jun 15 07:19 file3.txt -rw-r--r--. 1 root root 18 Jun 15 07:18 file4.txt -rw-r--r--. 1 root root 104 Jun 15 07:27 file5.txt -rw-r--r--. 1 root root 0 Jun 15 07:40 file6.txt -rw-r--r--. 1 root root 22179 May 26 22:40 install.log -rw-r--r--. 1 root root 5890 May 26 22:38 install.log.syslog root@nginx02 ~ # cat > file6.txt <<EOF > sdfsdf > adfasdf > agda > asd > asdg > adfs > EOF root@nginx02 ~ # ll total 64 -rw-------. 1 root root 1073 May 26 22:40 anaconda-ks.cfg -rw-r--r--. 1 root root 0 Jun 15 07:36 EOF -rw-r--r--. 1 root root 51 Jun 15 07:19 file1.txt -rw-r--r--. 1 root root 28 Jun 15 07:36 file2.txt -rw-r--r--. 1 root root 51 Jun 15 07:19 file3.txt -rw-r--r--. 1 root root 18 Jun 15 07:18 file4.txt -rw-r--r--. 1 root root 104 Jun 15 07:27 file5.txt -rw-r--r--. 1 root root 34 Jun 15 07:42 file6.txt -rw-r--r--. 1 root root 22179 May 26 22:40 install.log -rw-r--r--. 1 root root 5890 May 26 22:38 install.log.syslog
相关文章推荐
- 关于fragmentPagerAdapter的冲突问题
- PHPStorm显示代码行号设置
- [YII2] 自定义组件,在YII框架中正常使用
- TFTP配置
- php 访问对象的属性(当属性的键名称为数字时)的方法 {}
- ThinkPHP空操作与命名空间
- php中 -> 和 => 和 :: 的用法 以及 self 和 $this 的用法
- ThinkPHP 控制器
- php经典算法
- [李景山php]每天laravel-20160901|Dispatcher-1
- [李景山php]每天laravel-20160901|Dispatcher-1
- [转] PHP开发通用型标题图片功能
- [李景山php]每天laravel-20160831|EventServiceProvider
- [李景山php]每天laravel-20160831|EventServiceProvider
- PHP中PHP_INT_SIZE和PHP_INT_MAX常量
- PHP数据类型有哪些?
- phpstorm配置xdebug
- 使用TinkPHP实现品字形布局
- ThinkPHP框架基础
- phpstorm