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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!