Question

What needs to be added to the gawk statement in the print command (between $3 and...

What needs to be added to the gawk statement in the print command (between $3 and $1 )to place a space between the output fields. Test this command, the output isn't very readable. Adding one thing to the command will improve readability. gawk '/chevy/ {print $3 $1}' cars.txt

0 0
Add a comment Improve this question Transcribed image text
Answer #1

gawk '/chevy/ {print $3 $1}' cars.txt

instead of print in above command we can use printf to improve the readability of the output, So if we use printf there we can format the output.

Ex:gawk '/chevy/ {printf("%3s\t%s\n", $3,$1) }' cars.txt

Here in this command we are adding tabs in between $3 and $1 contents. Like this we can format the string however we want using printf statement.

output screen

Add a comment
Know the answer?
Add Answer to:
What needs to be added to the gawk statement in the print command (between $3 and...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • how do you insert a print command that changes with what name you type? = Syst...

    how do you insert a print command that changes with what name you type? = Syst x Grades for Lewis Dickerson: [Sum X MindTap - Cengage Learning X Python Programming | Facebook X war Python: cengage.com/static/nb/ui/evo/index.html?deploymentid=58296224090012788153144858955&eISBN=9781337560115&id=8110005398.sn CENGAGE MINDTAP Programming Exercise 1.7 Instructions myinfo.py name = inpu 2 age = input 3 print (name Cools Write and test a program that accepts the user's name (as text) and age (as a number) as input. اراء The program should output a sentence...

  • 1) Write a single line UNIX command to list all sh files matching the multiple conditions...

    1) Write a single line UNIX command to list all sh files matching the multiple conditions below: • at directory "/home/test" • filename containing "exam" 2) Write a single line UNIX command to check if "/home/exam2" in the PATH variable. 3) How to obtain the value of command line arguments in a shell program? 4) Write a single line UNIX command to run an executable Java program Hello at background and output the number of lines in the result. 5)...

  • I have the following code....from the previous lab....the above needs to be added to what is...

    I have the following code....from the previous lab....the above needs to be added to what is already existing. ALSO MODIFY SEMAPHORES TO USE pthreads instead of the pipe constructs P() & V() #include <stdio.h> #include <string.h> #include <sys/types.h> #include <unistd.h> #include <sys/wait.h> #include <stdlib.h> #include <sys/stat.h> void printStat(char *filename); //Main int main(int argc, char *argv[]) { //Process Id (storing)    pid_t pid;    int j;    //printf("Welcome to Project Three\n”);    // For loop*/    for (j = 1; j...

  • Please complete in JAVA only PROBLEM: CHMOD is a command in the UNIX computer system. It...

    Please complete in JAVA only PROBLEM: CHMOD is a command in the UNIX computer system. It is the command used for giving users permissions to access and change files and directories. There are 3 classes of users. They are the owner, the group and others. The permissions given are: read(r, write(w) and execute(x). The argument of the CHMOD command is a 3-character octal number (ex. 526). When each digit of that number is converted to binary, the binary digits are...

  • all info in picture 3. Let's say that Marie added a new command: inc X that adds 1 to the value stored at memory location X. a. Is there an opcode available for this instruction? If so, what o...

    all info in picture 3. Let's say that Marie added a new command: inc X that adds 1 to the value stored at memory location X. a. Is there an opcode available for this instruction? If so, what opcode would you use? b. Show the RTN for the inc command. Bus 0 Main Memory MAR 2 PC MBR ALU AC InREG 6 OutREG 16-bit bus 4. Write a MARIE program that computes and outputs the absolute value of an input...

  • QUESTION 1 What will be the output of following Unix command: find / -name ‘*’ A....

    QUESTION 1 What will be the output of following Unix command: find / -name ‘*’ A. List all files and directories recursively starting from / B. List a file names * in / C. List all files in / directory D. List all files and directories in / directory QUESTION 2 Which command is used to extract a column/field from a text file / input. A. paste B. get C. cut D. tar QUESTION 3 Which command creates an empty...

  • 1. Explain the difference between the /etc/profile and the ~/.bash_profile file. Which one is executed first?...

    1. Explain the difference between the /etc/profile and the ~/.bash_profile file. Which one is executed first? 2. Edit your .bash_profile file as follows: 1. Welcome the user 2. Add your home directory to the path if it is not there 3. Set erase to the Backspace key using stty. 4. Type source .bash_profile. What is the function of the source command? 3. What is the default primary prompt? 1. Change the prompt to include the time of day and your...

  • Let fibonacci = [1, 1, 2, 3, 5, 8, 13]. What is the output of print(fibonacci[1:4])?...

    Let fibonacci = [1, 1, 2, 3, 5, 8, 13]. What is the output of print(fibonacci[1:4])? Select one: a. [1,2,3] b. [1,2,3,5] c. 1 2 3 d. 1 2 3 5

  • QUESTION 1 What statement would you use to print the phrase “Hello, world” and then start...

    QUESTION 1 What statement would you use to print the phrase “Hello, world” and then start a new line? QUESTION 2 What statement would you use to assign the value 32 to the variable cheeses? QUESTION 3 What statement would you use to read a value from keyboard input into the variable cheeses? QUESTION 4 What statement would you use to print “We have X varieties of cheese,” where the current value of the cheeses variable replaces X? QUESTION 5...

  • Description Create a polynomial class with linked lists and implement some basic functions. Specifications Polynomials are...

    Description Create a polynomial class with linked lists and implement some basic functions. Specifications Polynomials are stored in a linked list of Term objects (two classes: Polynomial and Term). Term objects have two data fields: coefficient and exponent, both positive integers. Polynomial will have some methods that create linked list functionality, but not all list operations are needed; include only those used by this program. Do not use a separate linked list class. The list will be non-circular. Make a...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT