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里看不出来。

Subscribe

Related articles

Interpreting Marriage in Dreams: Good or Bad

Dreaming of marriage can symbolize unity or commitment in waking life. It may reflect a desire for partnership or emotional fulfillment. However, it could also represent anxieties about commitment or fears of loss of freedom. Remember that dream interpretations are subjective and can vary based on personal beliefs and experiences.

Romantic NYC Date Ideas: 10 Perfect Spots to Impress Your Date

Looking for a special date idea in NYC? From picnics in Central Park to sunset cocktails in Brooklyn, there are countless romantic spots to explore with your special someone. Let's discover the best options for an unforgettable date night in the Big Apple.

Who Should Attend the Bridal Shower? Your Complete Guide

The bridal shower is a special occasion where the bride is surrounded by her close family and friends. Traditionally, the guest list includes the bridal party, close relatives, and female friends who will celebrate with the bride ahead of her big day.

Ultimate Bach Party Gifts for the Bride-to-Be

Are you looking for the perfect gifts to celebrate the bride-to-be at her bachelorette party? From personalized items to pampering sets, we have the top picks to make her feel special before her big day.

Unveiling the Mystery: What is a Promise Ring and Its Romantic Significance

A promise ring is a symbol of commitment between couples. It represents a promise to be faithful and to one day marry. It is a romantic gesture that signifies a deep and meaningful relationship.

Enchanting Veil Hairstyles to Complete Your Bridal Look

Discover the elegance and romance of veil hairstyles. From soft waves to intricate updos, veils can be the perfect addition to any bridal look.

Unveiling the Magic of a Day-of Coordinator

A day of coordinator is like a behind-the-scenes magician, ensuring that every detail of your special day runs smoothly. They orchestrate the events with grace and precision, so you can focus on the romance and joy of your wedding day.

Unveiling the Magic of a Bridal Shower: What You Need to Know

A bridal shower is a cherished pre-wedding tradition where the bride-to-be is showered with love, gifts, and well wishes from close friends and family. It's a time for celebration and laughter as the bride prepares for her big day.
spot_imgspot_img

LEAVE A REPLY

Please enter your comment!
Please enter your name here