Crimean News
News of Crimea - The latest news of Crimea today. Events and incidents, economics and finance, sports, science, culture, resorts, society and politics in Crimea. Crimean news for the last day. Sevastopol News

awk学习笔记

awk是一种用于处理数据和生成报告的编程语言。
一般的使用格式是:

awk ‘{pattern + action}’ {filenames}

pattern指在每一行中进行匹配的条件,action指针对符合条件的行进行的操作,filenames是输入的文件名。
假设data文件中有以下数据:

1 donald 305 20050129
2 chin 102 20040129
3 mark 304 20040229

下面对这个文件进行操作:

awk ‘{print $1, $2, $3, $4}’ data

输出:

1 donald 305 20050129
2 chin 102 20040129
3 mark 304 20040229


awk ‘{print $1″t», $2″t», $3″t», $4}’ data

输出:

1 donald 305 20050129
2 chin 102 20040129
3 mark 304 20040229

这里显示的格式并不是输出的真实格式,真实格式是中间会有一个tab符号,格式对的很整齐,只不过在html里看不出来。

Find out more:  Студенты проходят практику в севастопольской госветслужбе
Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More

Privacy & Cookies Policy