%, %%, #, ## 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
0 声望1 粉丝