cat command to view the contents of the file and some common parameters

Format
cat [option]… [file]…

[root@centos8 ~ ]#cat /data/all.log 
bin
boot
data
dev
etc
home
lib
lib64
media
mnt
opt
proc
root
run
sbin
srv
sys
tmp
usr

parameter effect
-E Display line ending character $
[root@centos8 ~ ]#cat -E /data/all.log 
bin$
boot$
data$
dev$
etc$
home$
lib$
lib64$
media$
mnt$
opt$
proc$
root$
run$
sbin$
srv$
sys$
tmp$
usr$
var$
parameter effect
-E Display line ending character $
[root@centos8 ~ ]#cat > /data/test <<EOF
> a 
> a b
>  a b c
> EOF
[root@centos8 ~ ]#cat -E /data/test
a $
a b$
 a b c$
parameter effect
-A Show all control characters
[root@centos8 ~ ]#cat -A /data/test1
a $
a b$
a^Ib^Ic^I$
$
$
parameter effect
-n Number each row displayed
[root@centos8 ~ ]#cat -n /data/test
     1	a 
     2	a b
     3	 a b c
parameter effect
-b Non-blank lines are numbered, which is equivalent to nl
[root@centos8 ~ ]#cat -b /data/test1
     1	a 
     2	a b
     3	a	b	c	

     4	a b c d
parameter effect
-s Compress consecutive blank lines into one line
[root@centos8 ~ ]#cat -n /data/test1
     1	a 
     2	a b
     3	a	b	c	
     4	
     5	
     6	
     7	
     8	
     9	a b c d
    10	
[root@centos8 ~ ]#cat -s /data/test1
a 
a b
a	b	c	

a b c d

[root@centos8 ~ ]#cat -ns /data/test1
     1	a 
     2	a b
     3	a	b	c	
     4	
     5	a b c d
     6	

tac command: reverse display text information

[root@centos8 ~ ]#cat /data/test
a 
a b
 a b c
[root@centos8 ~ ]#tac /data/test
 a b c
a b
a 

rev command: reverse display the content of the same line

[root@centos8 ~ ]#cat /data/test
a 
a b
 a b c
[root@centos8 ~ ]#rev /data/test
 a
b a
c b a 

Guess you like

Origin blog.csdn.net/weixin_50904580/article/details/109283836