【发布时间】:2013-04-16 01:03:26
【问题描述】:
如何将文件传递给 perl 脚本进行处理,并为多行 perl 脚本使用 heredoc 语法?我试过了,但没有运气:
cat ng.input | perl -nae <<EOF
if (@F==2) {print $F[0] . "\t". $F[1] . "\n"} else { print "\t" . $F[0] . "\n" }
EOF
cat ng.input | perl -nae - <<EOF
if (@F==2) {print $F[0] . "\t". $F[1] . "\n"} else { print "\t" . $F[0] . "\n" }
EOF
【问题讨论】:
-
所有你需要的是
perl -ple'$_="\t$_"if!/\t/'(如果@F!=2 当@F