【发布时间】:2013-07-13 13:40:19
【问题描述】:
我想将ps -ef 的输出逐行传送到python。
我正在使用的脚本是这个(first.py) -
#! /usr/bin/python
import sys
for line in sys.argv:
print line
不幸的是,“行”被分成了由空格分隔的单词。所以,例如,如果我这样做
echo "days go by and still" | xargs first.py
我得到的输出是
./first.py
days
go
by
and
still
如何编写脚本以使输出为
./first.py
days go by and still
?
【问题讨论】: