原题:
Write a command line that counts how many times the word 'for' appears in python files (files that end with .py) within your current directory. The resulting number should be placed in a file called 'result
下面是我写的命令,但是不知道如何修改能实现输出到某个文件中的功能
grep -o for *.py | wc -l

试写一个linux命令行,可以统计所有python程序中for出现的次数,并将结果输出到某个文件中
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
1条回答 默认 最新
- COCO_AS 2017-09-02 00:44关注
重定向到文件就好了:
grep -R -o for *.py | wc -l >abc.txt
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报