zoukankan      html  css  js  c++  java
  • cat命令查看文件显示行号

    cat显示行号

    cat -n

    使用cat看长文件,尤其是配置文件,没有行号很不方便。

    使用cat命令时,添加参数-n,可以在查看时显示行号。

    e.g.
    查看日志的配置文件

    [root@C8-3 ~]# cat -n /etc/rsyslog.conf 
         1	# rsyslog configuration file
         2	
         3	# For more information see /usr/share/doc/rsyslog-*/rsyslog_conf.html
         4	# or latest version online at http://www.rsyslog.com/doc/rsyslog_conf.html 
         5	# If you experience problems, see http://www.rsyslog.com/doc/troubleshoot.html
         6	
         7	#### MODULES ####
         8	
         9	module(load="imuxsock" 	  # provides support for local system logging (e.g. via logger command)
        10	       SysSock.Use="off") # Turn off message reception via local log socket; 
        11				  # local messages are retrieved through imjournal now.
        12	module(load="imjournal" 	    # provides access to the systemd journal
        13	       StateFile="imjournal.state") # File to store the position in the journal
        14	#module(load="imklog") # reads kernel messages (the same are read from journald)
        15	#module(load"immark") # provides --MARK-- message capability
        16	
        17	# Provides UDP syslog reception
        18	# for parameters see http://www.rsyslog.com/doc/imudp.html
        19	#module(load="imudp") # needs to be done just once
        20	#input(type="imudp" port="514")
        21	
        22	# Provides TCP syslog reception
        23	# for parameters see http://www.rsyslog.com/doc/imtcp.html
        24	#module(load="imtcp") # needs to be done just once
        25	#input(type="imtcp" port="514")
        26	
        27	#### GLOBAL DIRECTIVES ####
        28	
        29	# Where to place auxiliary files
        30	global(workDirectory="/var/lib/rsyslog")
        31	
        32	# Use default timestamp format
        33	module(load="builtin:omfile" Template="RSYSLOG_TraditionalFileFormat")
        34	
        35	# Include all config files in /etc/rsyslog.d/
        36	include(file="/etc/rsyslog.d/*.conf" mode="optional")
        37	
        38	#### RULES ####
        39	
        40	# Log all kernel messages to the console.
        41	# Logging much else clutters up the screen.
        42	#kern.*                                                 /dev/console
        43	
        44	# Log anything (except mail) of level info or higher.
        45	# Don't log private authentication messages!
        46	*.info;mail.none;authpriv.none;cron.none                /var/log/messages
        47	
        48	# The authpriv file has restricted access.
        49	authpriv.*                                              /var/log/secure
        50	
        51	# Log all the mail messages in one place.
        52	mail.*                                                  -/var/log/maillog
        53	
        54	
        55	# Log cron stuff
        56	cron.*                                                  /var/log/cron
        57	
        58	# Everybody gets emergency messages
        59	*.emerg                                                 :omusrmsg:*
        60	
        61	# Save news errors of level crit and higher in a special file.
        62	uucp,news.crit                                          /var/log/spooler
        63	
        64	# Save boot messages also to boot.log
        65	local7.*                                                /var/log/boot.log
        66	
        67	
        68	# ### sample forwarding rule ###
        69	#action(type="omfwd"  
        70	# An on-disk queue is created for this action. If the remote host is
        71	# down, messages are spooled to disk and sent when it is up again.
        72	#queue.filename="fwdRule1"       # unique name prefix for spool files
        73	#queue.maxdiskspace="1g"         # 1gb space limit (use as much as possible)
        74	#queue.saveonshutdown="on"       # save messages to disk on shutdown
        75	#queue.type="LinkedList"         # run asynchronously
        76	#action.resumeRetryCount="-1"    # infinite retries if host is down
        77	# Remote Logging (we use TCP for reliable delivery)
        78	# remote_host is: name/ip, e.g. 192.168.0.1, port optional e.g. 10514
        79	#Target="remote_host" Port="XXX" Protocol="tcp")
    
    * * * 胖并快乐着的死肥宅 * * *
  • 相关阅读:
    18款在线代码片段测试工具
    毫秒必争,前端网页性能最佳实践
    如何判断Javascript对象是否存在
    推荐10款免费的在线UI测试工具
    揭开Socket编程的面纱
    使用 jQuery Ajax 在页面滚动时从服务器加载数据
    对Android开发者有益的40条优化建议
    web api+递归树型结构
    asp.net Lodop实现批量打印
    asp.net lodop单个打印
  • 原文地址:https://www.cnblogs.com/bpzblog/p/14066293.html
Copyright © 2011-2022 走看看