+ -
当前位置:首页 → 问答吧 → 弱弱的问一句awk跟sed的区别是什么

弱弱的问一句awk跟sed的区别是什么

时间:2011-05-13

来源:互联网

面试题哦,请认真回答

作者: chinaboywg   发布时间: 2011-05-13

本帖最后由 南极雨 于 2011-05-13 10:23 编辑

确实很弱哦..
占个沙发了....
区别嘛...对于高手来说没什么区别,
个人意见: awk更灵活,细致 ..

作者: 南极雨   发布时间: 2011-05-13

FYI:


QUOTE:
1) What is the difference between awk and sed ?

Both are tools that transform text. BUT awk can do more things besides just manipulating text. Its a programming language by itself with most of the things you learn in programming, like arrays, loops, if/else flow control etc You can "program" in sed as well, but you won't want to maintain the code written in it.

2) What kind of application are best use cases for sed and awk tools ?

Conclusion: Use sed for very simple text parsing. Anything beyond that, awk is better. In fact, you can ditch sed altogether and just use awk. Since their functions overlap and awk can do more, just use awk. You will reduce your learning curve as well.




QUOTE:
sed is a stream editor. It works with streams of characters on a per-line basis. It has a primitive programming language that includes goto-style loops and simple conditionals (in addition to pattern matching and address matching). There are essentially only two "variables": pattern space and hold space. Readability of scripts can be difficult. Mathematical operations are extraordinarily awkward at best.

awk is oriented toward delimited fields on a per-line basis. It has much more robust programming constructs including if/else, while, do/while and for (C-style and array iteration). There is complete support for variables and single-dimension associative arrays plus (IMO) kludgey multi-dimension arrays. Mathematical operations resemble those in C. It has printf and functions. The "K" in "AWK" stands for "Kernighan" as in "Kernighan and Ritchie" of the book "C Programming Language" fame (not to forget Aho and Weinberger). One could conceivably write a detector of academic plagiarism using awk.

作者: xiaopan3322   发布时间: 2011-05-13

楼上厉害!

作者: dzhxc   发布时间: 2011-05-13

都让楼上回答完了。

:emn10:

作者: ajdan4q   发布时间: 2011-05-13

这个三两句也说不清楚吧,都用于文本处理。

作者: zooyo   发布时间: 2011-05-13

弱弱的回答:倚天剑和屠龙刀的区别

作者: yinyuemi   发布时间: 2011-05-13



QUOTE:
这个三两句也说不清楚吧,都用于文本处理。
zooyo 发表于 2011-05-13 10:43




    说不清楚也得说 面试问的 难道你回答 说不清楚吗?

作者: chinaboywg   发布时间: 2011-05-13