sort
格式:
sort [ 选项] [ 参数]
-f
-b
-M
-n
-r
-u
-t
-o
-k
tr
格式:
tr [ 选项] [ 参数]
参数:
-c:取代所有不属于第一字符集的字符
-d:删除所有属于第一字符集的字符
-s:把连续重复的字符以单独一个字符表示
-t:先删除第一字符集较第二字符集多出的字符
cut
cut :列截取工具
选项 :
-b :按字节截取
-c :按字符截取,常用于中文
-d :指定以什么为分隔符截取,默认为制表符
-f :通常和-d一起用,匹配第几列
uniq
格式:
uniq [ 选项] 参数
参数:
-c 进行计数
-d 仅显示重复行
-u 仅显示出现一次的行
免交互
EOF
[ root@localhost ~]
> hello
> world
> EOF
hello
world
[ root@localhost ~]
> [ test]
> name = test
> baseurl = file:///mnt
> enabled = 1
> gpgcheck = 0
> EOF
[ root@localhost ~]
[ test]
name = test
baseurl = file:///mnt
enabled = 1
gpgcheck = 0
[ root@localhost ~]
cat <<- EOF
hello
EOF
cat << EOF
hello
EOF
[ root@localhost ~]
hello
hello
[ root@localhost ~]
grep $1 << 'EOF'
pete $100
joe $200
sam $ 25
bill $ 9
EOF
[ root@localhost ~]
bill $ 9
[ root@localhost ~]
grep $1 <<- 'EOF' //-表示忽略前导制表符
pete $100
joe $200
sam $ 25
bill $ 9
EOF
[ root@localhost~ ]
bill $ 9
expect
[ root@localhost ww]
[ root@localhost~]
set timeout 10
set user root
set ip 192.168 .43.100
set pass 123456
spawn ssh $user @$ip 了,
expect {
"(yes/no)"
{ send "yes\r " ; }
"password:"
{ send "$pass \r " ; }
}
expect "#"
send "ls\r "
send "ifconfig ens33\r "
send "exit\r "
expect eof
[ root@localhost ~]
spawn ssh root@192.168.43.100
root@192.168.43.100's password:
Last login: Thu Jun 10 11 :47:17 2021 from 192.168 .43.55
[ root@localhost ~]
anaconda-ks.cfg initial-setup-ks.cfg J user.sh 公共 模板 视频 图片 文档 下载 音乐 桌面
[ root@localhost ~]
ens33: flags = 416 3 < UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168 .43.100 netmask 255.255 .255.0 broadcast 192.168 .43.255
inet6 fe80::976c:f4a0:edcc:9ae7 prefixlen 64 scopeid 0x20 < link>
ether 00:0c:29:3f:67:c5 txqueuelen 1000 ( Ethernet)
RX packets 657550 bytes 929968663 ( 886.8 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 269078 bytes 18774253 ( 17.9 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[ root@localhost ~]
登出
Connection to 192.168 .43.100 closed.
expect -c " //在bash环境引用expect
spawn ssh root@192.168.43.100
expect \" password:\" { send \" 123456\r \" }
expect \" ]#\" { send \" infconfig ens33\r \" }
expect eof
"