我只是想测试我在杂志(Linux Shell Handbook)上看到的东西。我从来没有真正尝试过这样的事情,但我知道这可能很有用
例子是
perl -n -e '/^The \s+(.*)$/ print "$1\n"' heroes.txt
在 heros.txt 它有
Catwoman
Batman
The Tick
Spider-Man
Black Cat
Batgirl
Danger Girl
Wonder Woman
Luke Cage
Ant-Man
Spider-Woman
这应该显示 Tick,但是我得到了
perl -n -e '/^The \s+(.*)$/ print "$1\n"' heroes.txt
syntax error at -e line 1, near "/^The \s+(.*)$/ print"
Execution of -e aborted due to compilation errors.
我哪里错了??