awk FS field separate with examples
awk separate string, you can use awk FS variable or awk -F option to support single delimiter and multiple delimiter regular matching....
awk array operations with examples
Awk array, it supports associative array, the index is a number or a string. awk array syntax: array_name[index]=value...
How to remove lines with specific line number from text file with awk or sed in Linux/unix
Remove specific line numbers in linux/unix, use awk NR variable to delete a specific line numbers, use sed command action option "d" to delete a...
How to using multiple delimiters in awk and sed
Multiple delimiter-separated fields in awk or sed.
Using awk command:
➜ awk -F'[:=|]' '{print $1, $2, $3}' test.log;
Using sed command:
➜ sed 's/[:=|]/ /g' test.log...
AWK tutorial: awk group by count
When we are dealing with log files, we often need to count the number of times some keywords appear. For example, count the number of...
awk merge files base on the keyword
use the awk variables NR and FNR merge files base on the keywords.
awk -F' ' 'NR==FNR{a[$1]=$2;}NR!=FNR{print $0, a[$1]}' test-4.txt test-5.txt...
awk custom function and examples
Here, you need to use the awk custom function to implement the abs function. awk 'function abs(x){return (x < 0) ? -x : x;} {print...
AWK tutorial: awk -F and awk BEGIN{ FS … }
Usually, when I use awk for text processing, I prefer to use the awk -F option for text field separation. Of course, we can also...
awk loop example: awk for and while
awk for loop:
awk -F"#" '{for(i=1;i<=NF;i++) { ... }' t.txt; awk for loop array:
awk 'BEGIN{a["km"] = "m";a["kn"] = "n";for(i in a) {...}}'; awk while loop:
awk -F"#"...
AWK tutorial: three ways of awk execution
Linux awk command execution ways: 1. Command line execution Detailed introduction of syntax, see 《Linux awk》 2. Shell script file execution Explanation: !/usr/bin/awk The first...
awk NR FNR difference
Linux awk command can use variables NR and FNR to process multiple files. NR : ordinal number of the current record, multiple files self-increase FNR...
AWK tutorial: awk sort uniq
In daily development, we often use awk command to cut and sort log file columns and count them. awk sort uniq count example awk column...
AWK tutorial: awk [-F] print example
- awk print last field
- print line number per line
- print specific columns
- use -F specifies a delimiter...
AWK tutorial: awk remove last character
awk remove last character use awk length and substr functions...
awk command tutorial in linux/unix with examples and use cases
linux awk tutorial: syntax, options, workflow, built-in variables, built-in functions, custom functions, conditional judgment, and usage examples....