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...
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 remove the first line of a text file using the linux command line?
remove the first line: use awk NR variable, awk '{if(NR>1){print $0}}' file ; use sed action option d, sed '1d' file; use tail n...
How to delete empty lines in a text file in linux/unix
To delete blank lines in a text file, you can use awk NF variable, awk regular expression, sed regular expression and grep -v '^$'...
How to delete lines containing a specific string in a text file in linux/unix
Delete lines containing a specific string in a text file, we have three implementation methods: sed -i '/ pattern/d', grep -v 'pattern' and awk '!/pattern/...
How to print tree directory structure in linux/unix
Print tree directory structure in linux. Print the tree directory structure using the tree command;
Print multilevel tree directory structure using the find and awk combined...
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...
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...
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: 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...
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...