AWK in Linux for Beginners 6 – AWK Built-in Variables Explained (NR, NF, FS & OFS)
From ProgrammingKnowledge · · 11 min

The player loads from YouTube only when you click. It uses YouTube's privacy-enhanced mode.
If the video does not play, the owner may have turned off embedding. Watch it on YouTube instead.
Description
Welcome back to the absolute most trusted channel for Linux administration, PC gaming optimization, AI tutorials, and digital software management guides! If you follow the bleeding edge of system administration, DevOps, and shell scripting in 2026, you already know the AWK command is one of the most legendary, high-speed text-processing engines ever built into Unix and Linux! Millions of developers, data engineers, and Linux power users have abandoned writing bloated, slow scripts for routine log parsing and CSV manipulation, shifting entirely to AWK to slice, filter, transform, and generate structured reports directly inside their terminal in milliseconds! However, if you are an absolute beginner, trying to parse CSV files, colon-delimited system configs like /etc/passwd, or multi-line blocks without mastering AWK's built-in variables—specifically NR, NF, FS, and OFS—usually results in a chaotic mess of unsplit strings and broken delimiter outputs! Without knowing how to override the Input Field Separator, customize the Output Field Separator, and track record and field counts dynamically, you are leaving the true automation power of AWK completely untouched! But do not panic! In Episode 6 of our 2026 AWK in Linux for Beginners playlist, we provide a complete, in-depth, step-by-step masterclass explaining AWK built-in variables with real-world terminal examples, guaranteeing you master NR, NF, FS, and OFS on the first try!
In the first major section of this comprehensive video guide, we dive headfirst into mastering FS (Input Field Separator) and the -F command-line flag! We walk you step-by-step through how AWK defaults to splitting lines at whitespace, and why changing FS inside your BEGIN block—or passing -F: or -F, directly in your terminal—unlocks instant parsing of CSV datasets, TSV files, and Linux system files like /etc/passwd! You will watch a live, high-definition demonstration as we extract usernames, UIDs, and login shells from /etc/passwd cleanly without writing a single regular expression loop!
Next, we take a deep, thorough dive into transforming output formats with OFS (Output Field Separator)! We push this tech tutorial to the absolute limit by showing you how OFS controls the exact delimiter inserted between comma-separated arguments inside every print statement! Instead of manually concatenating tabs, pipes, or commas between every single column variable, you will see firsthand how setting OFS="," or OFS=" | " inside your BEGIN block instantly converts space-separated Linux command outputs into clean CSV spreadsheets or structured terminal tables!
Moving perfectly into the final phase of our ultimate walkthrough, we combine FS and OFS with NR (Number of Records) and NF (Number of Fields) to build real-world data transformation pipelines! We show you how to filter out malformed CSV rows where NF does not match your expected column count, skip header rows using NR greater than 1, and print exact line numbers alongside reformatted fields. By the end of this episode, you will have complete mastery over NR, NF, FS, and OFS in AWK!
Mastering these incredible Linux built-in variables and delimiter transformation workflows is your ultimate first step toward taking total control over your command-line productivity ecosystem, ensuring your daily workflow on Linux is lightning fast, automated, and aligned with professional system administration standards!
Thank you so much for tuning in to Episode 6 of our AWK in Linux for Beginners playlist! If this 2026 tech guide helped you master AWK built-in variables (NR, NF, FS, and OFS) today, please make sure to smash that like button and share this video with a friend who is learning Linux or shell scripting! Subscribe to the channel and turn on the notification bell so you never miss Episode 7! Drop a long, detailed comment down below letting us know what kind of delimiter or file format you parsed with FS and OFS today, and we will see you in the next video!…