青年旅舍网站开发背景及意义,上海网页设计报价,商务网络设计实验报告,西安论坛iwenhou趁周末#xff0c;复习一下鸟哥的linux私房菜#xff0c;看了文件内容查阅部分#xff0c;做个笔记#xff0c;哈哈#xff0c;希望对你有帮助哦。catcat : 由第一行开始显示文件所有内容参数说明cat [-AbEnTv] 参数#xff1a; -A : 相当于-vET 的整合参数#…iwenhou趁周末复习一下鸟哥的linux私房菜看了文件内容查阅部分做个笔记哈哈希望对你有帮助哦。catcat : 由第一行开始显示文件所有内容参数说明cat [-AbEnTv] 参数 -A : 相当于-vET 的整合参数可列出一些特殊字符而不是空白而已
-b 列出行号仅针对非空白行做行号显示空白行不标行号
-E 将结尾的断行字符$显示出来
-n : 打印行号连同空白行也会有行号与-b的参数不同范例demo范例一查看cattest.txt的内容[rootiZ2zehkwp9rwg4azsvnjbuZ whx]# cat cattest.txt
test cat command
jaywei
#####范例二查看cattest.txt的内容并且显示行号[rootiZ2zehkwp9rwg4azsvnjbuZ whx]# cat -n cattest.txt 1 test cat command 2 jaywei 3 4 #####适用场景cat是Concatenate的缩写主要功能是将一个文件的内容连续显示在屏幕上面。一般文件内容行数较少时如40行之内适合用cat。如果是一般的DOS文件时就需要特别留意一些奇怪的符号例如断行与[Tab]等要显示出来就得加入-a之类的参数了。tactac : 从最后一行开始显示可以看出tac是cat的倒写形式范例demo[rootiZ2zehkwp9rwg4azsvnjbuZ whx]# tac cattest.txt ##### jaywei test cat command适用场景tac 的功能跟cat相反cat是由“第一行到最后一行连续显示在屏幕上”而tac则是“由最后一行到第一行反向在屏幕上显示出来”。headhead 显示文件开头的内容以行为单位默认文件开头的前10行参数说明head [OPTION]... FILE... -n行数 显示的行数 -q 隐藏文件名 -v 显示文件名 -c字节 显示字节数范例demo显示 sentinel.conf 文件前12行.[rootiZ2zehkwp9rwg4azsvnjbuZ redis-4.0.7]# head -n 12 sentinel.conf
# Example sentinel.conf
# *** IMPORTANT ***
#
# By default Sentinel will not be reachable from interfaces different than
# localhost, either use the bind directive to bind to a list of network
# interfaces, or disable protected mode with protected-mode no by
# adding it to this configuration file.
#
# Before doing that MAKE SURE the instance is protected from the outside
# world via firewalling or other means.
#tail查看文件的内容也是以行为单位默认10行从尾往前看。监听Java动态日志时一般跟 -f参数配合使用。参数说明tail [参数] [文件]
-f 循环读取
-q 不显示处理信息
-v 显示详细的处理信息
-c数目 显示的字节数
-n行数 显示文件的尾部 n 行内容范例一显示sentinel.conf文件的最后12行[rootiZ2zehkwp9rwg4azsvnjbuZ redis-4.0.7]# tail -n 12 sentinel.conf
# role is either leader or observer
#
# The arguments from-ip, from-port, to-ip, to-port are used to communicate
# the old address of the master and the new address of the elected slave
# (now a master).
#
# This script should be resistant to multiple invocations.
#
# Example:
#
# sentinel client-reconfig-script mymaster /var/redis/reconfig.sh范例二持续检测sentinel.conf的内容[rootiZ2zehkwp9rwg4azsvnjbuZ redis-4.0.7]# tail -f sentinel.conf
# The arguments from-ip, from-port, to-ip, to-port are used to communicate
# the old address of the master and the new address of the elected slave
# (now a master).
#
# This script should be resistant to multiple invocations.
#
# Example:
#
# sentinel client-reconfig-script mymaster /var/redis/reconfig.sh
要等到输入[ctrl]-c 之后才离开tail 这个命令的检测范例三持续检测sentinel.conf的内容并匹配redis关键字。匹配关键字一般用 grep tail 一般也会跟 grep搭档使用。[rootiZ2zehkwp9rwg4azsvnjbuZ redis-4.0.7]# tail -f sentinel.conf | grep redis
# sentinel client-reconfig-script mymaster /var/redis/reconfig.sh
要等到输入[ctrl]-c 之后才离开tail 这个命令的检测适用场景tial-f 被用来动态监听Java日志开发联调经常使用到它一般跟 grep 一起搭档使用。moremore 一页一页地显示文件内容参数说明more [-dlfpcsu] [-num] [/pattern] [linenum] [fileNames..] 参数 -num 一次显示的行数 -p 不以卷动的方式显示每一页而是先清除萤幕后再显示内容 -c 跟 -p 相似不同的是先显示内容再清除其他旧资料 -s 当遇到有连续两行以上的空白行就代换为一行的空白行 /pattern 在每个文档显示前搜寻该字串pattern然后从该字串之后开始显示 -u 不显示下引号 根据环境变数 TERM 指定的 terminal 而有所不同 num : 从第 num 行开始显示 fileNames 欲显示内容的文档可为复数个数常用操作命令[rootiZ2zehkwp9rwg4azsvnjbuZ redis-4.0.7]# more sentinel.conf
# Example sentinel.conf
...(中间省略) ...
# Note that whatever is the ODOWN quorum, a Sentinel will require to
# be elected by the majority of the known Sentinels in order to
# start a failover, so no failover can be performed in minority.
#
# Slaves are auto-discovered, so you dont need to specify slaves in
--More--(29%)仔细看上面的范例如果more后面接的文件内容行数大于屏幕输出的行数时就会出现类似上面的图示。重点在最后一行最后一行会显示出目前显示的百分比而且还可以在最后一行输入一些有用的命令。在more这个程序的运行过程中你可以使用一些常用的操作命令空格键 代表往下翻一页Enter : 代表往下滚动一行/字符串 代表在这个显示的内容当中向下查询“字符串” 这个关键字:f :立刻显示出文件名以及目前显示的行数q :代表立刻离开more不再显示该文件内容b或[Ctrl]-b :代表往回翻页不过这操作只对文件有用对管道无用。最常用的是按 q离开按 空格键往下翻页按 b往回翻页以及 /字符串搜索功能请看以下demo范例demo范例一[rootiZ2zehkwp9rwg4azsvnjbuZ redis-4.0.7]# more -10 sentinel.conf
# Example sentinel.conf
...(此处省略)...
# Before doing that MAKE SURE the instance is protected from the outside
--More--(4%)分页查看sentinel.conf文件一页展示10行。按下 空格键可以往下翻页[rootiZ2zehkwp9rwg4azsvnjbuZ redis-4.0.7]# more -10 sentinel.conf
# Example sentinel.conf
...(此处省略)...
# protected-mode no
# port sentinel-port
# The port that this sentinel instance will run on
--More--(7%)按下 b可以回退到上一页# *** IMPORTANT ***
...(此处省略)...
# Before doing that MAKE SURE the instance is protected from the outside
# world via firewalling or other means.
--More--(5%)按下 q可以立刻离开more[rootiZ2zehkwp9rwg4azsvnjbuZ redis-4.0.7]# 范例二如果想在sentinel.conf文件中搜寻sentinel关键字可以这样做[rootiZ2zehkwp9rwg4azsvnjbuZ redis-4.0.7]# more -10 sentinel.conf
# Example sentinel.conf
...(此处省略)...
# Before doing that MAKE SURE the instance is protected from the outside
/sentinel 输入/之后光标就会自动跑到最下面一行等待输入如同上面的说明输入了/之后光标就会跑到最下面一行并且等待你的输入你输入了字符串并按下[Enter]之后more就会开始向下查询该字符串而重复查询同一个字符串可以直接按下n即可。最后不想看了就按下q离开more。# Before doing that MAKE SURE the instance is protected from the outside
/sentinel
...skipping
# protected-mode no
# port sentinel-port
# The port that this sentinel instance will run on
port 26379
# sentinel announce-ip ip
# sentinel announce-port port
#
/
...skipping
# Example:
#
# sentinel announce-ip 1.2.3.4
# dir working-directory
# Every long running process should have a well-defined working directory.
# For Redis Sentinel to chdir to /tmp at startup is the simplest thing
# for the process to dont interfere with administrative tasks such as
# unmounting filesystems.
--More--(23%)适用场景more适合日志比较大的文件查看可以一页一页查看不会让前面的数据看不到。lessless 与 more 类似但less的用法比起more又更加有弹性。若使用了less时就可以使用下、下等按键的功能来往前往后翻看文件。除此之外在less里头可以拥有更多的查询功能。不止可以向下查询也可以向上查询。常用操作命令空格键往下翻动一页[pagedown]向下翻动一页[pageup]向上翻动一页Enter : 代表往下滚动一行y 向前滚动一行/字符串向下搜索字符串的功能?字符串向上搜索字符串的功能n重复前一个搜索与 / 或 ? 有关N反向重复前一个搜索与 / 或 ? 有关q: 离开less这个程序b 向后翻一页范例demo范例一在sentinel.conf文件中搜寻sentinel关键字如下less sentinel.conf输入反斜杠 /输入关键字 sentinel回车重复前一个搜索可以按n反向重复前一个搜索按N范例二Linux 动态查看日志文件一般用tail -f 但是我们也可以用less F 实现。less file-name 命令 F tail -f file-name我们经常用tail -f grep 关键字动态查找报错的日志也可以用less实现。先输入shirftg到达文件结尾然后输入 输入搜索关键字如 sentinel回车然后按 n键往上搜索效果是不是也不错尤其日志文件动态刷新太快的时候奸笑脸。适用场景less适合日志比较大的文件查看可以一页一页查看并且比more更灵活也可以动态查看日志我一般用它查看Java日志。小结本文总结了查看日志的几个linux命令cat、tac、head、tail、more、less其中less真的很适合日常开发日志查看非常推荐less。原文链接https://blog.csdn.net/weiwenhou/article/details/102774286