Latest Posts
Tags
awk awk -F awk examples background run script bash awk command grep linux curl disk space docker commands docker usage du find and grep Google Analytics grep -v grep examples java java example linux awk linux command linux find linux grep linux ls ls -al ls -lrt ls examples ls sort ls sort by size mkdir mv examples mysql mysql column to row mysql example rm rmdir sed sed examples sed tutorial seo Shell tutorial top vim vim examples vim tutorial w wordpress
Tag Archives: linux awk
How to use awk concatenate string in linux/unix
Awk concatenated strings, you can use awk OFS variables, or you can use strings directly. syntax: awk’BEING {s1=”string1″;s2=”string2″;OFS=”delimiter”;print s1,s2;}’ Continue reading
Posted in Awk Command, How to, Text Processing
Tagged awk concatenate string, awk examples, linux awk
Comments Off on How to use awk concatenate string in linux/unix
How to use awk to select substring in linux/unix
Awk substr has built-in functions that can help us select substrings anywhere in the input string. awk substr syntax: substr(string, start, lenght) Continue reading
Posted in Awk Command, Text Processing
Tagged awk examples, awk substr, linux awk
Comments Off on How to use awk to select substring in linux/unix
awk ternary condition judgment and examples
Awk ternary condition judgment is similar to the awk if else statement, providing branch control capability. Ternary syntax: ( Statement ) ? True : False ; Continue reading
Posted in Awk Command, Text Processing
Tagged awk examples, awk ternary, linux awk
Comments Off on awk ternary condition judgment and examples
awk OFS field separator with examples
Awk OFS field separator variable, output field separator. It is a pair with the Awk FS variable; awk FS separates strings as fields, and awk OFS connection fields as strings. Continue reading
Posted in Awk Command, Text Processing
Tagged awk examples, awk OFS, awk separator, linux awk
Comments Off on awk OFS field separator with examples
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. Continue reading
Posted in Text Processing, Awk Command
Tagged awk delimiter, awk examples, awk fs, awk separate, linux awk
Comments Off on awk FS field separate with examples
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 Continue reading
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 specific line numbers Continue reading
Posted in How to, Awk Command, Sed Command, Text Processing
Tagged awk examples, linux awk, sed examples
Comments Off on How to remove lines with specific line number from text file with awk or sed in Linux/unix
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
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 awk examples, awk group by, linux awk, linux command
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 awk examples, awk merge files, awk NR FNR, linux awk
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 awk examples, awk function, linux awk, linux command
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 awk -F, awk begin fs, awk examples, linux awk, linux command
Comments Off on AWK tutorial: awk -F and awk BEGIN{ FS … }
awk loop example: awk for and while
awk for loop:
awk -F”#” ‘{for(i=1;iContinue reading
Posted in Awk Command, Text Processing
Tagged awk examples, awk for loop, awk while loop, linux awk
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 awk examples, awk exec, linux awk, linux command
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