Signal9Signal9 — home
online
back to labs

Dojo: Count the Fields

EasyOne-Liner Dojo8 min
The brief

The first line of /root/record.txt is a whitespace-separated record and you need to know how many fields it has. In ONE line, print that field count and write just the number to /root/answer.txt.

awk already splits every line into fields and exposes the count as NF — no need to translate spaces and count them by hand. Read NF on the first line.

What you'll do
  • Write the number of whitespace-separated fields on line 1 of /root/record.txt to /root/answer.txt, in one line

Hands-on lab: you work on a real Linux box in your browser, graded on the machine's actual state.