Question
Write an awk command that will take a file named list.txt and only print the odd numbered lines. (Do not put the awk code in
Write an awk command that will take a file named list.txt and only print the odd numbered lines. (Do not put the awk code in a separate file, do it from the command line).
a. awk '(NR % 2)==1 {print}' list.txt
b. awk -odd '{print}' list.txt
c. awk 'select odd line {print}' list.txt
d. awk 'NR ~ odd {print}' list.txt
-------------------------------------------------------
Suppose the first field of each line is supposed to be an integer. Choose the an awk command that would print out an error message if that field is not an integer.
a. if ($1 !~ /^[0-9]+$/) print "error"
b. if ($1 != /^[0-9]+$/) print "error"
c. if ($1 != /[0-9]+/) print "error"
d. if ($field1 != number) print "error"
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started