Perl、Python、AWK、sed 之间有哪些区别?处理文本使用那种脚本语言比较好?理由是什么?

如果有其他的脚本语言,也请列举
关注者
143
被浏览
39,909

12 个回答

  • sed - when you need to do simple text transforms on files.
  • awk - when you only need simple formatting and summarization or transformation of data.
  • perl - for almost any task, but especially when the task needs complex regular expressions.
  • python - for the same tasks that you could use Perl for.

这里回答很全了: stackoverflow.com/quest
awk的使用场合蛮有趣的,很多任务可以用awk来处理,比如今晚,我下了个字幕发现同时有中英文字幕,占屏幕很大块儿,然后一句话就可以去掉英文字幕:
gawk.exe "$0 !~ /^[a-zA-Z]/ {print $0}" 1.srt > 2.srt

:)