Q:

extracting first line from file using awk command

I've been going through an online UNIX course and have come across this question which I'm stuck on. Would appreciate any help!

You are provided with a set of files each one of which contains personal details about an individual. Each file is laid out in the following format, with one file per individual:
name:Niko Tanaka 
age:41 
occupation:Doctor

I know the answer has to be in the form:
n=$(awk -F: '   /   /{print }'  filename)

A:

awk 'NR==1' filename

Result
name:Niko Tanaka

A:

n=$(awk -F: '/name/{print $2}' infile)

Whatever is inside of / / are regular expressions. In this case you just want to match on the line that contains 'name'.

