$ awk -F ":" 'NR!=1 {print $1}' test1.txt
what does this mean?? especially ":"??

Dani AI

Generated

A short, plain answer for (and following up on 's suggestion to read the man page):

The command tells awk to use a colon as the field separator, skip the first input record, and print the first field of each remaining line. In everyday terms: it prints the text before the first colon on every line except the very first line of input.

A few useful details and pitfalls:

  • The -F option sets awk's field separator (FS). A single colon is fine; shells usually accept -F: or -F ':'. FS can be a regular expression, not just a single character.
  • NR is the number of the current record across all files. If you want to skip the first line of each file when processing multiple files, use FNR instead of NR.
  • $1 is the first field; NF is the number of fields. Empty lines or unexpected separators can produce empty fields, so check NF if needed.

Quick alternatives (examples):

awk -F: 'FNR>1 {print $1}' filename

or use cut -d: -f1 for a simpler field-extraction if you only need the first column.

For more detail, consult the GNU Awk manual: GNU Awk User's Guide.

hi,

man awk is very explicit about what is -F
about what is NR, too.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.