Linux Complentary

%, %%, #, ## Matching Rule

file_txt="example.a.b"   

# %notation cut from right to left of string, including .*
ngreedy=${file_txt%.*} # ngreedy = "example.a"
greedy=${file_txt%%.*} # greedy = "example"

# #notation cut from left to right of string, including .*
ngreedy=${file_txt#*.} # ngreedy = "a.b"
greedy=${file_txt##*.} # greedy = "b"

expect shell

expect shell is a shell in Linux, like bash

spawn: an encapsulation of ssh command, expect: listen output, send: input, interact: hold

# Example
set timeout 30 # in seconds
spawn ssh host
expect {"password:" {send "$PASSWORD\n"; exp_continue} } # exp_continue start from expect
interact
    原文作者:Lycheeee
    原文地址: https://segmentfault.com/a/1190000013320552
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞