Toggle navigation
Log in
Sign Up
Log in
Sign Up
Appium
C
C#
C++
Docker
Go
Informatica
Java
JavaScript
Kafka
Numpy
Oracle
Pandas
PHP
Python
R
React Native
Scipy
SFTP
Tableau
Teradata
TGMC
UNIX
Forget_Code.Models.CategoryViewModel
Add a new snippet
AWK
1
Choose Category
NR - Number of Records in AWK in UNIX
Forget Code
UNIX
NR - Number of Records in AWK
NR is a AWK built-in variable and it denotes number of records being processed.
Usage : NR can be used in action block represents number of line being processed and if it is used in END it can print number of lines totally processed
Example : Using NR to print line number in a file using AWK
awk '{print NR, $0;}' test.txt
test.txt contents
ray
shawn
eliza
Output of awk command
1 ray
2 shawn
3 eliza
Note : When multiple files are used, NR count is incremental. If you want to get relative count with respect to the file, use
FNR
instead.
Tags for NR - Number of Records in AWK in UNIX
awk test record number
awk reord number
awk print records by line number
awk print line with number of records
awk NR%number
awk count records
“nr” in “awk” denotes
Contribute to Forget Code, help others.
Add snippet