语法:

  连接显示

选项:

  -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 & 文件结束符的更多相关文章

  1. linux下文件结束符

    linux下文件结束符,我试过了所有的linux,发现其文件的结束符都是以0a即LF结束的,这个是操作系统规定的,windows下是\r\n符结束,希望可以帮助大家. -------------转:来 ...

  2. 文件结束符和C\C++读取文件方式

    http://www.cnblogs.com/cvbnm/articles/2003056.html 约定编译器为 gcc2/x86: 所以 char, unsigned char 为 8 位, in ...

  3. Windows环境下C++中关于文件结束符的问题

    参考资料:http://www.cnblogs.com/day-dayup/p/3572374.html 一.前言 在不同的OS环境下,程序中对应的文件结束符有所不一样,根据<C++ Prime ...

  4. 关于windows下的文件结束符

    在<c++ primer>中有说,在windows中文件结束符为:ctrl+z,在Linux中为:ctrl+D. 但是在while(cin>>s)的语句运行中,需要两次的^Z, ...

  5. linux 下vim文件乱码 cat文件正常处理方法

    linux 下vim文件乱码 cat文件正常处理方法 服务器支持中文字符集,cat和其他查看文件命令现在正常,vim还是出现了中文乱码问题, 1.查看文件编码格式 vim 文件 :set fileen ...

  6. 关于文件结束符EOF

    EOF 是 End Of File 的缩写. 在 C 语言中,它是在标准库中定义的一个宏. 人们经常误认为 EOF 是从文件中读取的一个字符(牢记).其实,EOF 不是一个字符,它被定义为是 int ...

  7. linux cat 文件操作

    简略版: cat主要有三大功能:1.一次显示整个文件.$ cat filename2.从键盘创建一个文件.$ cat > filename     只能创建新文件,不能编辑已有文件.3.将几个文 ...

  8. linux cat 文件编码

    test.log是utf-16的编码 cat test.log会报错 但是我们可以cat的时候指定编码格式 iconv -f 文件编码 -t 终端编码 input.log iconv -f utf-1 ...

  9. Linux cat文件正常,vim文件乱码

    cat: vim: 1.临时解决 vim 文件后,命令模式下执行: :set encoding=utf-8 2.永久解决 vi    配置文件路径:/etc/virc vim 配置文件路径:/etc/ ...

随机推荐

  1. MySQL程序只mysqlbinlog详解

    mysqlbinlog命令详解 mysqlbinlog用于处理二进制的日志文件,如果想要查看这些日志文件的文本内容,就需要使用mysqlbinlog工具 用法: mysqlbinlog [option ...

  2. SpringMVC和Struts是线程安全的吗?为什么?

    线程不安全的.(其实我觉得回答为:存在线程安全问题 这样比较好点) 原因如下: 第一点,先理解为何线程不安全 1 struts1的action是单例的,所以存在线程安全问题(struts2是多例的,不 ...

  3. angularjs 外部调用controller中的方法

    angular.element(document.querySelector('[ng-controller=mainCtrl]')).scope().viewGo('tab.VIPPay_Succe ...

  4. linux(ubuntu)下安装phantomjs

    1.安装phantomjs ubuntu下sudo apt-get install phantomjs下载的不能用 —-下载程序文件 到官网下载 1.安装phantomjs —-下载程序文件 wget ...

  5. [InfluxDB] 安装与配置

    [InfluxDB] 安装与配置 1- 下载 ubtuntu: wget https://dl.influxdata.com/influxdb/releases/influxdb_1.5.2_amd6 ...

  6. 在MacOSX系统上的一些工具和问题汇总

    Android 模拟器 1. 安装模拟器 点击链接:https://cloud.genymotion.com/page/launchpad/download 需要先注册登录一下. 2.安装Virtua ...

  7. 黄聪:wordpress教程

    又一个作品完成!<跟黄聪学Wordpress主题开发>,国内最好的Wordpress主题模版开发视频教程!! 目录预览: WordPress官方源文件层式结构讲解 WordPress数据库 ...

  8. JVM 专题

    未完待续>>> JVM - 整体结构 摘抄自:<分布式java应用基础与实践>-第三章 JVM - 内存 对上图各部分的概要解释: JVM - GC 详情参考: http ...

  9. 无法清除cookie中的属性值之对解决问题的思考

    关于如何快速解决一个自己知识以外的问题的思考 做好任何事情都是讲究方法的,这是我健身之后的一个领悟,用正确的方式做事,自己的付出才能有价值. 首先分析问题: 比如我想清除cookie里面的token, ...

  10. ObjectId与DateTime的互相转换

    s会用mongdb中经常会需要用到通过“_id”去检查数据,筛选数据,但是想根据具体时间的id每次都需要做一下转换,这样搜索起来就很简单了. ObjectId转DateTime /// <sum ...