cat & 文件结束符
语法:
连接显示
选项:
-n,显示行号。
-v,显示不可见打印符。
-E,显示“行结束符”($)。
显示行号
$ cat -n /etc/fstab
/dev/VolGroup00/LogVol00 / ext3 defaults
LABEL=/boot /boot ext3 defaults
tmpfs /dev/shm tmpfs defaults
devpts /dev/pts devpts gid=,mode=
sysfs /sys sysfs defaults
proc /proc proc defaults
/dev/VolGroup00/LogVol01 swap swap defaults
打印行末结束符
$ cat -E /etc/fstab
/dev/VolGroup00/LogVol00 / ext3 defaults $
LABEL=/boot /boot ext3 defaults $
tmpfs /dev/shm tmpfs defaults $
devpts /dev/pts devpts gid=,mode= $
sysfs /sys sysfs defaults $
proc /proc proc defaults $
/dev/VolGroup00/LogVol01 swap swap defaults $
直接输入命令,就会进入交互模式。直到cat接到一个“文件结束符”时停止交互。
$ cat
hello
hello
are you busy?
are you busy?
$
重写程序(case语句的第一个例子“找工作时联系人信息”),使用“文件结束符”,格式化显示交互信息:
#!/bin/bash cat << EOF
Recruitment Announcement
Are you ready to apply for any job?
accounting
cashier
secretary
Please enter a number to select the corresponding positions.
EOF echo -n "Choice: "
read NUM
case $NUM in
)
printf "call mr wang. number is 1124\n"
;;
)
printf "call miss li. number is 1233.\n"
;;
)
printf "call miss ji. number is 1367.\n"
;;
*)
printf "If you want to make a lot of money, to be a seller. call 1498.\n"
;;
esac
打印程序的提示信息:
display_help () {
cat << EOF
Usage: findTom [OPTION]
View the tomcat information.
View the home directory of the tomcat program running on the system, and
the project path.
Mandatory arguments to long option are mandatory for short options too.
-r, --read
view the previously running tomcat information.
-v, --version
view the version
--clear
when the number of row is greater than , then clean-up, and leaving lines.
-h, --help
display this help and exit
E-mail bug reports to: <@qq.com>
EOF
}
执行上边的代码,效果如下:
$ ./cat.sh
Recruitment Announcement
Are you ready to apply for any job?
accounting
cashier
secretary
Please enter a number to select the corresponding positions.
Choice:
从程序的输出看出,脚本里的文本格式原样在交互界面显示了。
文件结束符:
Linux: CTRL + d
Windows: CTRL + z
cat & 文件结束符的更多相关文章
- linux下文件结束符
linux下文件结束符,我试过了所有的linux,发现其文件的结束符都是以0a即LF结束的,这个是操作系统规定的,windows下是\r\n符结束,希望可以帮助大家. -------------转:来 ...
- 文件结束符和C\C++读取文件方式
http://www.cnblogs.com/cvbnm/articles/2003056.html 约定编译器为 gcc2/x86: 所以 char, unsigned char 为 8 位, in ...
- Windows环境下C++中关于文件结束符的问题
参考资料:http://www.cnblogs.com/day-dayup/p/3572374.html 一.前言 在不同的OS环境下,程序中对应的文件结束符有所不一样,根据<C++ Prime ...
- 关于windows下的文件结束符
在<c++ primer>中有说,在windows中文件结束符为:ctrl+z,在Linux中为:ctrl+D. 但是在while(cin>>s)的语句运行中,需要两次的^Z, ...
- linux 下vim文件乱码 cat文件正常处理方法
linux 下vim文件乱码 cat文件正常处理方法 服务器支持中文字符集,cat和其他查看文件命令现在正常,vim还是出现了中文乱码问题, 1.查看文件编码格式 vim 文件 :set fileen ...
- 关于文件结束符EOF
EOF 是 End Of File 的缩写. 在 C 语言中,它是在标准库中定义的一个宏. 人们经常误认为 EOF 是从文件中读取的一个字符(牢记).其实,EOF 不是一个字符,它被定义为是 int ...
- linux cat 文件操作
简略版: cat主要有三大功能:1.一次显示整个文件.$ cat filename2.从键盘创建一个文件.$ cat > filename 只能创建新文件,不能编辑已有文件.3.将几个文 ...
- linux cat 文件编码
test.log是utf-16的编码 cat test.log会报错 但是我们可以cat的时候指定编码格式 iconv -f 文件编码 -t 终端编码 input.log iconv -f utf-1 ...
- Linux cat文件正常,vim文件乱码
cat: vim: 1.临时解决 vim 文件后,命令模式下执行: :set encoding=utf-8 2.永久解决 vi 配置文件路径:/etc/virc vim 配置文件路径:/etc/ ...
随机推荐
- grep 正则问题 this version of PCRE is compiled without UTF support
问题 在使用grep -P,出现如下报错: grep: this version of PCRE is compiled without UTF support 原因 有些系统支持的正则规范不同. 解 ...
- SDI工程时钟路径分析
SDI工程时钟路径分析 //------------- Receive Ports - RX Fabric Output Control Ports ------------- output rxou ...
- Video Test Pattern Generator(7.0)软件调试记录
Video Test Pattern Generator(7.0)软件调试记录 . XVidC_VideoMode XVIDC_VM_576_50_I = XVIDC_VM_720x576_50_I ...
- Pandas的使用(1)
Pandas的使用(1) 1.绘图 import pandas as pd import numpy as np import matplotlib.pyplot as plt ts = pd.Ser ...
- Team Foundation Server 2010简体中文版
文件名称:Team Foundation Server 2010简体中文版 文件大小:1.8 GBhttp://www.google.com/profiles/dedecms.com 下载地址: th ...
- 胖子哥的大数据之路(7)- 传统企业切入核心or外围
一.引言 昨天和一个做互联网大数据(零售行业)的朋友交流,关于大数据传统企业实施的切入点产生了争执,主要围绕两个问题进行了深入的探讨: 问题1:对于一个传统企业而言什么是核心业务,什么是外围业务? 问 ...
- python+selenium自动化软件测试(第3章):unittes
From: https://blog.csdn.net/site008/article/details/77622472 3.1 unittest简介 前言 (python基础比较弱的,建议大家多花点 ...
- 服务网关zuul之五:熔断
路由熔断 当我们的后端服务出现异常的时候,我们不希望将异常抛出给最外层,期望服务可以自动进行一降级.Zuul给我们提供了这样的支持.当某个服务出现异常时,直接返回我们预设的信息. 如果没有配置fall ...
- hessian 反序列化问题
有class 比如 class Test{ private TestArrayList list=new TestArrayList(""); public static void ...
- Jmeter(七)Jmeter脚本优化(数据与脚本分离)
午休时间再来记一记,嗯..回顾着使用Jmeter的历程,想着日常都会用到的一些功能.一些组件:敲定了本篇的主题----------是的.脚本优化. 说起脚本优化,为什么要优化?又怎么优化?是个永恒的话 ...