If you have other scripting languages, please also list the reply content if you have other scripting languages:
- 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 cocould use Perl.
Here the answer is very full: http://stackoverflow.com/questions/366980/what-are-the-differences-between-perl-python-awk-and-sed
AWK is very powerful in text processing. For convenience, you may use it with sed, because sed can easily use regular expressions, in terms of regularization, awk is weaker. For example, when processing text, you may first use sed for preliminary processing, and then use awk to reduce the logic complexity. As for python, you can also process text. However, if the processing logic is not very complex, we recommend that you use awk. Because of the same complexity logic, python usually has a large amount of code.The usage of awk is quite interesting. Many tasks can be handled by awk. For example, tonight, I wrote a subtitle and found that there are both Chinese and English Subtitles at the same time, which is a huge part of the screen, then you can remove the English subtitles in one sentence:
Gawk.exe "$0 !~ /^ [A-zA-Z]/{print $0} "1.srt> 2.srt
:) Perl, Ruby, and Python are sorted in descending order of Recommendation indexes and learning difficulty. Sed/awk is used for simple processing. Do not use Regex or Awk one-liner language to process text. It is always the best to use the most familiar generic language, multi-step processing, and multi-intermediate variable and multi-line processing, this is easy to understand and troubleshoot.
In addition to being "Compact", one-liner is useless.
If you don't know any of them, you can try it. Which one is the best, and someone around you can ask.
Which language can do a lot of work.
Python can do anything.
Awk mainly covers statistics and reports.
Sed mainly lies in regular expressions, but looks dizzy. Perl is the first choice in text processing. It is easy to replace awk sed with one line. It is also easy to write readable programs. It depends on how you use it. Some Beginners use perl to make 4 different, perl is a language with higher development efficiency. It never works as well as java with policysed. It is mainly used for batch replacement.
Here is a trick. sed should not use the default/as the separator, which is too troublesome. Generally, I use # or other characters, such @.
Sed-n "s # a # B # gp" to verify whether it is correct,
Sed-I "s # a # B # g" change the file
Clearly separate the input data, filter, and change the output format. For example, to print a field separately, use awk to make it easier.
Generally, complex statistics, such as multi-row statistics, use python, that is, 3 or 4 rows.
It is said that perl is powerful and never used... The main reason is that the regular expression is not good. I always think that a string of regular expressions is the same as that of tianshu.