-
#!/bin/bash
-
content=
'Line'
-
expect <<EOF
-
set
file
"hello.txt"
-
set
fd [
open
\$
file
r]
-
set
n 0
-
while
{[gets \$fd line] != -1} {
-
incr n
-
puts
"$content\$n: \$line"
-
}
-
close \$fd
-
EOF
1.
#!/usr/bin/expect -f
set
fd [
open
/etc/passwd
r]
set
data [
read
$fd]
puts $data
### 这样就可以输出每一行
close $fd
转载于:https://blog.51cto.com/yanjiu/1745142