gpt4 book ai didi

hadoop - 混淆了awk中的[01459],什么意思?

转载 作者:可可西里 更新时间:2023-11-01 14:43:44 25 4
gpt4 key购买 nike

#!/usr/bin/env bash
for year in all/*
do
echo -ne `basename $year .gz`"\t"
gunzip -c $year | \
awk '{ temp = substr($0, 88, 5) + 0;
quality = substr($0, 93, 1);
if (temp !=9999 && quality ~ /[01459]/ && temp > max) max = temp }
END { print max }'
done

我正在学习 Hadoop 权威指南第 4 版中的练习。我已经完成了第一个练习,并且有效,但是我不明白quality ~/[01459]/ 的含义。

最佳答案

根据 http://www.math.utah.edu/docs/info/gawk_5.html

exp ~ /regexp/

This is true if the expression exp (taken as a string) is matched by regexp.

[...]

This is called a character list. It matches any one of the characters that are enclosed in the square brackets.

因此 quality ~/[01459]/true 如果 quality 包含任何 1, 4, 5, 9

关于hadoop - 混淆了awk中的[01459],什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32508920/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com