我需要编写一个模仿linux命令wc
的perl(包括和特别是输出格式),在实现了功能的同时,wc
的输出真的很头疼,看起来它正在改变所有时,以下是几个例子(I将使用□表示空格字符)
1. wc test_input_1
⇒□□705673□□4234032□26754553□test_input_1
2. wc test_input_2
⇒□14□□79□581□test_input_2
3. wc test_input_2 -w
⇒79□test_input_2
4. wc test_input_2 -wc
⇒□79□581□test_input_2
5. cat test_input_2 | wc
⇒□□□□□14□□□□□□79□□□□□581
6. cat test_input_2 | wc -w
⇒79
⇒□□□□□79□□□□□581
linux命令wc输出格式
的人都知道WC是如何格式化输出?任何帮助表示赞赏,非常感谢。
看起来它只是在知道它时输出文件名。什么是如此复杂?为什么你不得不模仿这个而不是'exec'ing'wc'? – drysdam 2011-04-25 12:55:12