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...
3) Write the awk command that would show the user wmorales (or yourself) that is online...
3) Write the awk command that would show the user wmorales (or yourself) that is online (you have to use a pipe) Output, depending on the system that you are using or the command to find the users online, but it would be similar to: wmorales pts/37 10.32.9.93 13:58 1.00s 0.15s 0.10s w or wmorales pts/8 2020-04-25 12:22 (c-71-59-237-122.hsd1.or.comcast.net) YOUR AWK COMMAND: (10 points hard one) - 4) use who to show the the users on our system that have...
Do not use awk. Using the fixed length field file called famous.dat, make a one-line Unix...
Do not use awk. Using the fixed length field file called famous.dat, make a one-line Unix command - using pipe(s) - to display an alphabetical list of the last and first names in upper case of the last 8 people in the file. Hint: Names are in columns 6 through 35. Output is this.. DARWIN         CHARLES       EINSTEIN       ALBERT        GALILEO        GALILELI      GOLDMAN        EMMA          LOVELACE       ADA           MANDELA        NELSON        PARKS          ROSA          RUSSELL        BERTRAND Hint:  famous.dat uses space(s) to separate the fields
Use C++ to write a program that reads in a binary string from the command line...
Use C++ to write a program that reads in a binary string from the command line and applies the following (00, 1101) tag-system: if the first bit is 0, deletes the first three bits and append 00; if the first bit is 1, delete the first three bits and append 1101. Repeat as long as the string has at least 3 bits. Try to determine whether the following inputs will halt or go into an infinite loop: 10010, 100100100100100100. Use...
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...
The Java program should be able to do the following: accepts one command line parameter. The...
The Java program should be able to do the following: 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 in...
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
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT