请教一个题目
发表于 : 2010-12-11 13:07
谢谢各位。搞好了
代码: 全选
#! /usr/bin/perl
open(PASSWD , "/etc/passwd");
chomp(@pws = <PASSWD>);
for (@pws) {
@line = split /:[^\/]+/;
print "$line[0] 's home is $line[1]\n";
}
报错了 syntax error near unexpected token `PASSWD'trigger 写了:代码: 全选
#! /usr/bin/perl open(PASSWD , "/etc/passwd"); chomp(@pws = <PASSWD>); for (@pws) { @line = split /:[^\/]+/; print "$line[0] 's home is $line[1]\n"; }
应该怎么执行?trigger 写了:你是怎么执行的?
不需要权限的,就是把[code"][/code】换成相应的名字,如c,bash等trigger 写了:楼上怎么弄的GeSHi?需要什么论坛权限吗?
代码: 全选
#!/bin/bash
FILE="/etc/passwd"
while read line; do
[ "$line" == "::::::" ] && continue
echo $line | cut -d":" -f1,6 | \
sed -n -e "s/\(.*\):\(.*\)/\1's home directory is \2./p"
done < $FILE
代码: 全选
#!/usr/bin/expect --
log_user 0
set f [open /etc/passwd]
spawn -noecho -open $f
expect {
-re {([^:]*):[^:]*:[^:]*:[^:]*:[^:]*:([^:]*)[^\n]*\n} {
puts "$expect_out(1,string)'s home is $expect_out(2,string)"
exp_continue
}
eof
}
wait