JA50
1
Mike Harrington:(510) 548-1278:250:100:175
Christian Dobbins:(408) 538-2358:155:90:201
Susan Dalsass:(206) 654-6279:250:60:50
Need to learn how to print each record preceded by the number of the record using awk.
awk -F '|' '{print NF}'
would it be something like this?
This looks familiar... You even gave -F:
in your last post. Do you know why you tried -F'|'
this time? Do you want that as the output delimiter?
The entire record is $0. NF is number of fields in a record (5 for these). NR is the record number.
awk -F: '{print NR,$0}'
1 Like
nl infile
nl -s: infile
1:Mike Harrington:(510) 548-1278:250:100:175
2:Christian Dobbins:(408) 538-2358:155:90:201
3:Susan Dalsass:(206) 654-6279:250:60:50
4:Archie McNichol:(206) 548-1348:250:100:175
5:Jody Savage:(206) 548-1278:15:188:150
6:Guy Quigley:(916) 343-6410:250:100:175
7:Dan Savage:(406) 298-7744:450:300:275
8:Nancy McNeil:(206) 548-1278:250:80:75
9:John Goldenrod:(916) 348-4278:250:100:175
10:Chet Main:(510) 548-5258:50:95:135
11:Tom Savage:(408) 926-3456:250:168:200
12:Elizabeth Stachelin:(916) 440-1763:175:75:300
1 Like