Watch the latest (2021) tutorial on AWK command: • Video
AWK command
Actions:
This command is mostly used for pattern scanning and processing. It allows us to use variables, logical operations, numeric and string functions, etc.
Syntax:
awk 'pattern { actions } ' inputfile
Some built-in variables :
NR - Keeps the current count of the number of records
NF - Keeps the current count of the number of fields within the current input field
FS - Field Separator
RS - Record separator
ORS - Output Record Separator (Default ORS is newline)
OFS - Output Field Separator (Default ORS is blank space)
Below are some commands using awk:
awk '{print}' testfile.txt
awk '/TCS/{print}' testfile.txt
awk '/TCS/{print $1}' testfile.txt
awk '/TCS/{print $0}' testfile.txt
awk '/TCS/{print NR,$0}' testfile.txt
awk '{print NR,$0}' testfile.txt
awk '{if($4=="TCS")}{print NR,$0}' testfile.txt
awk '{if($4=="TCS")} END{print NR,$0}' testfile.txt
awk '{print $1,NF}' testfile.txt
awk '{print $1,$NF}' testfile.txt
awk '{print $1,$(NF-1)}' testfile.txt
awk 'NR==3, NR==4{print $1,$(NF-1)}' testfile.txt
awk 'NR==3, NR==6{print $1,$(NF-1)}' testfile.txt
awk '{print $1 ":"$(NF-1)}' testfile.txt
awk '{print $1,$(NF-1)}' testfile.txt
awk 'BEGIN{OFS=":";}{print $2,$NF}' testfile.txt
awk 'BEGIN{ORS=":";}{print $2,$NF}' testfile.txt
awk 'BEGIN{ORS="\n\n\n";}{print $2,$NF}' testfile.txt
awk '{print $2,$NF}' testfile.txt
======================
Important playlists
======================
Data Structures • Introduction to Data Structures
Linux: • How to use VIM/VI editor for beginner...
SonarQube: • Install and configure SonarQube serve...
======================
You can follow me on:
======================
Instagram: / engineerhooon
LinkedIn: / sunny-shaw
Github: https://github.com/sunny-shaw
Medium: / sunnyshaw_12357
=============================================================
|| Subscribe and hit the bell button to get latest content ||
=============================================================
Смотрите видео A quick tutorial on AWK command | Latest | Engineer онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Engineerhoon 30 Апрель 2020, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 1,997 раз и оно понравилось 44 людям.