感謝分享!稍稍修改了一下,就可以從1開(kāi)始選擇了
#!/bin/bash
file="computerInfo"
#顯示機(jī)器信息 過(guò)濾第一行和空行
awk '{if (NR > 1 && $1 != ""){printf "%-2s %-45s %-15s \n","("NR-1")",$5,$1}}' $file
echo "please choose which machine to login:"
read number
number=$[number+1]
#將信息存入變量
read ip port user password <<< $(echo `awk 'NR=="'$number'"{print $1,$2,$3,$4}' $file`)
./core.ex $ip $port $user $password
wyyl1 評(píng)論自Linux Expect 簡(jiǎn)介和使用實(shí)例