Linux Basics Practice Test: Awk Programming — Flashcards | Linux | FatSkills

Linux Basics Practice Test: Awk Programming — Flashcards

Fast review mode: answers are shown by default so you can skim quickly. Hide them if you want to self-test.

AWK is a Linux programming language and scripting tool that can process data and generate formatted reports. It's useful for text processing, pattern search, and manipulating text in documents. A basic AWK program consists of a pattern followed by an action enclosed in curly braces, such as awk 'pattern ( action )'. 

Here are some examples of AWK commands:
Printing specific columns:
To print the 2nd and 3rd columns, you can use the command `$ awk '(print $2 `\t'' $3)' file.txt
Basic function: To print "Don't Panic!", you can use the command `$ awk `BEGIN ( print \''Don't Panic!\'' )'' 

Here are some AWK options:
if-else:
Determines whether to perform an action based on a condition
while: Repeats a target statement while a condition is true
for: Creates a loop that executes a specific number of times
break: Exits from an enclosing while or for
 
AWK automatically splits each line into fields, and uses the space character to separate each field by default. You can change that by providing the command line parameter -F followed by the desired separator. 

Related Test: Unix Basics Practice Test: Awk Command Operations

1 of 29 Ready
Which one of the following is not true?
nawk does not provide the additional capabilities in comparison of awk
Shortcuts
Prev Space Show / hide Next
Turn this into a study set.
Sign in with Google to save tricky questions to your reminder list and resume on any device.
Sign in with Google Free • no extra password