Linux CLI - Text ProcessingWhich of these is the correct syntax to print the first field of each line using awk?Aawk '{print $}' file.txtBawk 'print $1' file.txtCawk '{print 1}' file.txtDawk '{print $1}' file.txtCheck Answer
Step-by-Step SolutionSolution:Step 1: Identify correct awk print syntaxThe print statement must be inside braces {} and use $1 to refer to the first field.Step 2: Check each optionawk '{print $1}' file.txt uses correct braces and $1. awk 'print $1' file.txt misses braces. awk '{print 1}' file.txt prints number 1 literally. awk '{print $}' file.txt uses invalid $.Final Answer:awk '{print $1}' file.txt -> Option DQuick Check:Print first field = awk '{print $1}' [OK]Quick Trick: Always use braces {} around actions in awk [OK]Common Mistakes:Omitting braces around printUsing $ without field numberPrinting literal numbers instead of fields
Master "Text Processing" in Linux CLI9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More Linux CLI Quizzes Disk and Storage - du (disk usage by directory) - Quiz 6medium Networking Commands - ping for connectivity testing - Quiz 13medium Pipes and Redirection - /dev/null for discarding output - Quiz 10hard Pipes and Redirection - stdin redirection (<) - Quiz 1easy Pipes and Redirection - Why pipes chain commands into workflows - Quiz 10hard Process Management - jobs command - Quiz 13medium Process Management - Background processes (&) - Quiz 9hard Searching and Finding - which and whereis for commands - Quiz 1easy Text Processing - sort and uniq - Quiz 6medium Text Processing - awk basics (field processing) - Quiz 1easy