Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Copy and paste your gawk program/command and screen output in a text document cars.txt file plym fury 1970 73 2500 chevy malibu 1999 60 3000
Copy and paste your gawk program/command and screen output in a text document
cars.txt file
plym fury 1970 73 2500 chevy malibu 1999 60 3000 ford mustang 1965 45 10000 volvo s80 1998 102 9850 ford thundbd 2003 15 10500 chevy maliby 2000 50 3500 bmw 325i 1985 115 450 honda accord 2001 30 6000 ford taurus 2004 10 17000 toyota rav4 2002 180 750 chevy impala 1985 85 1550 ford explor 2003 25 950
1. Run the following gawk command, which includes both a pattern and an action, selects all lines that contain the string chevy and displays the third and first fields from the selected lines: Run the following gawk command, gawk selects lines that contain a match for the regular expression h. Because there is no explicit action, gawk displays all the lines it selects 2. $ gawk '/h/" cars.txt 3. Run the following gawk command, the next pattern uses the matches operator()to select all ines that contain the letter h in the first field: $ gawk $1 /h/" cars.txt Run the following gawk command; the caret (A) in a regular expression forces a match at the beginning of the line (page 1014) or, in this case, at the beginning of the first field: 4. $ gawk $1 /Ah/" cars.txt example, gawk selects lines that have a second field that begins with t or m and displays the third and second fields, a dollar sign, and the fifth field. Because there is no comma between the "$" and the $5, gawk does not put a SPACE between them in the output. $gawk $2/A[tm/ (print $3, $2, "$" $51' cars.txt Run the following gawk command that shows three roles a dollar sign can play in a gawk program. First, a dollar sign followed by,a numbernames a field. Second, within a regular expression a dollar sign forces a match at the end of a line or field (5S). Third, within a string a dollar sign represents itself. 6. $gawk '$3 /5S/ (print $3, $1, "$" $5)' cars.txtStep 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