Question

In: Computer Science

**Need to use awk command in putty (should be a ONE LINE COMMAND) Write the command...

**Need to use awk command in putty (should be a ONE LINE COMMAND)

Write the command that would find all lines that have an email address and place a label email = before the line in the file longfile output will multiple lines similar to this one :

using a good awk command the output would be something like this

email = From: "Linder, Jann/WDC" <[email protected]>
email = To: Mr Arlington Hewes <[email protected]>
email = > From: Mr Arlington Hewes [SMTP:[email protected]]
email = > To: [email protected]

….etc...

---

the perfect output, but removing the duplicates( accomplished by using | uniq) would be even better:

email = [email protected]
email = [email protected]
email = [email protected]
email = [email protected]
email = [email protected]
email = [email protected]
email = [email protected]

…… etc ...

Solutions

Expert Solution

Note: I have provided two commands, you can use anyone according to your requirement.

Code to copy:

  1. awk '{   for (k=1;k<=NF;k++) {if ( $k ~ /[[:alpha:]]@[[:alpha:]]/ ) {print "email = " $k }}}' "longfile.txt"
  2. awk '/From:|To:|Cc:/ {printf ("email=%s\n" ,$0) ;}' longfile.txt

Output:


Related Solutions

write an awk script that works as wc command.
write an awk script that works as wc command.
Convert the following code from awk to Perl: (please don't use a2p (awk to perl) command)...
Convert the following code from awk to Perl: (please don't use a2p (awk to perl) command) Here was the original problem: Calculate the grade for each student that appears in the data file. You may calculate the grade based on total earned points, divided by total possible points. Or, for 10 points extra credit; Use the weighted totals for this course; available in the syllabus and on the course home page. Output a list of students, their grade as a...
The program should be able to do the following: In Java accepts one command line parameter....
The program should be able to do the following: In Java accepts one command line parameter. The parameter specifies the path to a text file containing the integers to be sorted. The structure of the file is as follows: There will be multiple lines in the file (number of lines unknown). Each line will contain multiple integers, separated by a single whitespace. reads the integers from the text file in part a into an array of integers. sort the integers...
PLEASE USE ARRAYS IN JAVA TO ANSWER THIS Write a 'main' method that examines its command-line...
PLEASE USE ARRAYS IN JAVA TO ANSWER THIS Write a 'main' method that examines its command-line arguments and calls the (add) method if the first parameter is a "+" calls the (subtract) method if the first parameter is a "-" calls the (doubled) method if the first parameter is a "&" add should add the 2 numbers and print out the result. subtract should subtract the 2 numbers and print out the results. Double should add the number to itself...
Introduction Write in C++ at the Linux command line a program that is the same as...
Introduction Write in C++ at the Linux command line a program that is the same as the previous collection app project but now uses a class to store the items and also can save the items to a file that can be read back into the array by the user when the program is re-started. You can use your project 1 submission as a starting point or you can do something new as long as it meets the listed requirements....
Write a C program called test that takes one command line argument, an integer N. When...
Write a C program called test that takes one command line argument, an integer N. When we run test: ./test N the program will do this: the parent process forks N child processes each child process prints its process ID, exits the parent process waits for all child processes to exit, then exits
Linux 1. Give a command line (one command) for displaying the files lab1, lab2, lab3, and...
Linux 1. Give a command line (one command) for displaying the files lab1, lab2, lab3, and lab4. Can you give another command lines that do the same thing by making use of the file name similarities? What is the command line for displaying the files lab1.c, lab2.c, lab3.c, and lab4.c? (Hint: use shell metacharacters.) 2. How to determine the number of users who are logged on to Linux server system at this time? What command did you use to discover...
I need to write a program in C with the following specification * ​​​​​​​Line one of...
I need to write a program in C with the following specification * ​​​​​​​Line one of the standard input will have the total number of people which must not be greater than 10 * Each of the subsequent lines of input will be the first name of a person and their number (ex. "Adam 85") one space between name and number * Each name must be a maximum of 14 characters * Put the first names into an array called...
Here are the tasks for this assignment: 1. Write a bash command line to determine if...
Here are the tasks for this assignment: 1. Write a bash command line to determine if the server 'syccuxfs01.pcc.edu' is reachable from the syccuxas01.pcc.edu server. 2. As you have read, TCP/IP messages are passed from one device to another until the message reaches its destination. Write a bash command line that will verify that no more than two (2) network devices are used to pass messages from the syccuxas01.pcc.edu server to the www.pcc.edu server. 3. Write a bash command line...
Write a program that takes two command line arguments at the time the program is executed....
Write a program that takes two command line arguments at the time the program is executed. You may assume the user enters only decimal numeric characters. The input must be fully qualified, and the user should be notified of any value out of range for a 23-bit unsigned integer. The first argument is to be considered a data field. This data field is to be is operated upon by a mask defined by the second argument. The program should display...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT