Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

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

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions