How to use the awk comparison operator
This article mainly introduces how to use the awk comparison operator, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.
For users using the awk command, it is convenient to use the comparison operator to filter text and strings when working with numbers or strings in a line of text. In the following section, we introduce the comparison operator of "awk".
What is the comparison operator in awk?
The comparison operator in awk is used to compare strings and or numeric values, including the following types:
Symbolic function
> greater than
< 小于 >= greater than or equal to
30 {print $0;} lines with a number of intact output less than or equal to 30.
Let me give you another example:
# awk'$3 20 {print $0;} 'food_list.txt
No Item_Name Quantity Price
1 Mangoes 45 $3.45
2 Apples 25 $2.45
3 Pineapples 5 $4.45 TRUE
4 Tomatoes 25 $3.45
5 Onions 15 $1.45 TRUE
6 Bananas 30 $3.45
In this example, we want to mark lines with a number less than or equal to 20 by adding (TRUE) at the end of the line.
Thank you for reading this article carefully. I hope the article "how to use the comparison operator of awk" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!