6
10
2014
2

awk 语句

1  awk '{if($5==18448)print $1" "$2" "$3" "$4" "$5}' fprintf_100.txt 

在fprintf_100.txt文件中,输出第五列的值为18448所在的行的第1,2,3,4,5列。输出的列与列之间用空格分开

 

2.  awk '{if($5==18448)print }' fprintf_100.txt 输出当前行的所有内容

 

3.  若第六列为字符A,则打印

awk '{if($6=="A")print }' sda.txt  记住比较字符要用双引号

 

4. awk做脚本,接受三个输入,输入1:比较数字   输入2:输入文件名  输入3: 输出文件名

#!/bin/sh
awk '{if($5=='$1')print}' $2 > $3 
其中括号中$5表示第五列,‘$1’表示第一个输入参数,$2表示第二个输入参数,$3表示第三个输入。注意这儿列$  以及第几个参数$ 不能混淆了
运行 ./run 510 input.txt output.txt
功能:检查input.txt的每一行,若该行第五列的数字为510,则输出至output.txt文件中
Category: Linux | Tags: awk | Read Count: 1075
Avatar_small
Digital Ali 说:
2021年9月05日 19:46

Wow, What an Outstanding post. I found this too much informatics. It is what I was seeking for. I would like to recommend you that please keep sharing such type of info.If possible, Thanks. soap 2 day

Avatar_small
Alyssa 说:
2023年1月06日 22:43

The awk statement is a programming language that is used for text processing and data extraction. It is often used for data analysis, business cbd oil drug test intelligence, and logging. The awk statement can be used to extract information from text files, CSV files, and other data sources. It can also be used to process and analyze data in real-time.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter

Host by is-Programmer.com | Power by Chito 1.3.3 beta | Theme: Aeros 2.0 by TheBuckmaker.com