Category Archives: Awk Command

AWK Command Tutorial: Common Usage Examples

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 Continue reading

Posted in Awk Command, File & Directory, How to, Sed Command, Text Processing | Tagged , , , , , , | 3 Comments

rename file linux – use rename cmd or mv cmd or awk cmd

Rename file in linux has two ways: linux rename command and linux mv command. linux rename command rename command – renames multiple files. Ubuntu is used as the test system, it does not have the remanae command installed by default. … Continue reading

Posted in File & Directory, Awk Command, Internet Technology | Tagged , , | 2 Comments

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 times the access log ip appears. Here we can use linux awk command to handle. … Continue reading

Posted in Awk Command, Text Processing | Tagged , , , | Comments Off on AWK tutorial: awk group by count

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 Continue reading

Posted in Awk Command, Text Processing | Tagged , , , | Comments Off on awk merge files base on the keyword

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 Continue reading

Posted in Awk Command, Text Processing | Tagged , , , | 1 Comment

AWK tutorial: find and kill process use awk

Step 1. View the process ID pid of the top command.
Step 2. Use the awk command to get the process ID.
Step 3. Use xargs kill to kill top process ID. Continue reading

Posted in Awk Command, Text Processing | Tagged , , , | 1 Comment

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 use the combination of BEGIN and FS to achieve the same goal. Let’s take a … Continue reading

Posted in Awk Command, Text Processing | Tagged , , , , | Comments Off on AWK tutorial: awk -F and awk BEGIN{ FS … }

AWK tutorial: awk regex example

What Is Regex?
Types of Regex:BRE and ERE.

Awk using BRE regex Patterns, Special Characters;

Awk using ERE regex Patterns, matches the start of text… Continue reading

Posted in Awk Command, Text Processing | Tagged , , | Comments Off on AWK tutorial: awk regex example

use the linux command to find the max value and print

Mostly used for log processing, there are several ways: first way: awk -v, second way: awk+sort+head, Third way: sed+sort+head, fourth way: sort -t+head … Continue reading

Posted in Awk Command, Sed Command | Comments Off on use the linux command to find the max value and print

Linux shell batch move files, delete spaces, rename files

1. Use linux find, move files in batch;
2. Use linux find, delete empty directories in batch;
3. Use shell while loop, batch delete spaces in file names;
4. Use linux awk batch rename files;

Continue reading

Posted in Awk Command | Tagged , , | Comments Off on Linux shell batch move files, delete spaces, rename files

awk loop example: awk for and while

awk for loop:
awk -F”#” ‘{for(i=1;iContinue reading

Posted in Awk Command, Text Processing | Tagged , , , | 1 Comment

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 line of #!/usr/bin/awk is the awk command location. use : ➜ which awk /usr/bin/awk 3. … Continue reading

Posted in Awk Command, Text Processing | Tagged , , , | Comments Off on AWK tutorial: three ways of awk execution

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 : ordinal number of the current record in the current file awk NR example Processing … Continue reading

Posted in Awk Command | Tagged , , , | 3 Comments

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 count linux Sort – n : sorted by the size of the value; – r … Continue reading

Posted in Awk Command, Text Processing | Tagged , , , | Comments Off on AWK tutorial: awk sort uniq

AWK tutorial: split on character awk or cut

In the previous article, we introduced the use of linux awk for string cutting. Here we introduce a method. use awk -F parameter use awk split function For more awk usage, please refer to the following article: Let’s look at … Continue reading

Posted in Awk Command, Text Processing | Tagged , , , | Comments Off on AWK tutorial: split on character awk or cut