Question

Use CAT and pipe to wc –l to get a count of the number of entries...

Use CAT and pipe to wc –l to get a count of the number of entries in ‘foo.txt’

Use SORT and pipe to UNIQ with the –c switch to output a list of duplicate lines preceded by the number of times the line occurs.
   Your output should look something like this:
       .

       .
       2 coo
      3 foo
       1 moo

Use SORT and pipe to UNIQ with the –d switch to output only repeated lines, rather than unique lines.   Your output should look something like:
       .
       .
       8
       9
       coo
       foo

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

foo.txt looks like this...

1) cat foo.txt | wc -l

The above command first will cat the file foo and will be piped to wc (word count) command with -l option to count number of lines.

2) sort foo.txt | uniq -c

First we will sort the file. Sort command sorts the lines by each and every charecter.

Then we will pipe to unique command which will display all lines once along with their count(using -c option).

3) sort foo.txt | uniq -d

First we will sort the file

Then we will pipe it to uniq command whith -d option which will only display repeated lines.

Add a comment
Know the answer?
Add Answer to:
Use CAT and pipe to wc –l to get a count of the number of entries...
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
  • What does the following command do: cat humans | sort | uniq | wc -l A....

    What does the following command do: cat humans | sort | uniq | wc -l A. reads the file "humans", sorts it, only retains unique lines, and counts the number of lines remaining B. reads the file "humans", sorts it, only retains the non-unique lines, and counts the number of lines remaining C. reads the files "cat" and "humans", sorts them, only retains lines with "uniq", and counts the number of lines remaining D. reads the files "cat" and "humans",...

  • Write a program that reads a sentence input from the user. The program should count the...

    Write a program that reads a sentence input from the user. The program should count the number of vowels(a,e,i,o,u) in a sentence. Use the following function to read the sentence. Should use switch statement with toupper. int read_line(char str[],int n) {    int ch, i=0;    while((ch =getchar()) != '\n')        if(1<n)            str[i++]==ch;    str[i] != '\0';    return i; } output should look like: Enter a sentence: and thats the way it is! Your sentence...

  • C homework help pipes

    Round 2: pipeline.cThis program takes the same input as sequence.c, but executes the commands as a pipeline, where the output of each command is piped to the input of the next command in line. The input of the first command, and the output of the final command, should not be altered. For example, if the file "cmdpipe" contains the linesls -s1sort -ntail -n 5then running./pipeline < cmdpipeshould output the 5 largest files in the current directory, in order of size.Suggested approach: set...

  • Write a complete C++ program that will: Declare a vector of integers Use a pointer to...

    Write a complete C++ program that will: Declare a vector of integers Use a pointer to dynamically allocate an array of 10 elements Ask the user how many values they would like to have in the data structures Read in the user’s response and make sure that it is greater than 20 (error loop) Generate the number of integers that the user asked for and store them into both data structures. The integer values should be unique unordered values (no...

  • UNIX is all about manipulating files and input/output streams fluidly, so it is important to get a strong grasp of how...

    UNIX is all about manipulating files and input/output streams fluidly, so it is important to get a strong grasp of how this fundamentally works at the system call level to understand higher-level system programming concepts. Every program automatically has three file descriptors opened by the shell standard input standard output standard error 1 2 One can use read and write other open file. Normally, standard input and output on the terminal are line-buffered, so, for example, the specified number of...

  • home / study / engineering / computer science / computer science questions and answers / Write...

    home / study / engineering / computer science / computer science questions and answers / Write A Second Game Program That Prints A Chart To The Screen Showing The Randomness Of A Die. ... Question: Write a second game program that prints a chart to the screen showing the randomness of a die. Th... Write a second game program that prints a chart to the screen showing the randomness of a die. The game should first prompt the client for...

  • NOTE – You may use C++ - but you MAY NOT use #include <string> The goal...

    NOTE – You may use C++ - but you MAY NOT use #include <string> The goal is to use C-Style character array based strings. You will put all of your code in this file. You may use any technique we have learned so far. Specifications: This assignment is split into several parts. The goal is to get you used to working with C/C++ run-time arrays and strings. Part 0 – Create a Menu You should create a menu that gives...

  • CSC110 Lab 6 (ALL CODING IN JAVA) Problem: A text file contains a paragraph. You are to read the contents of the file, store the UNIQUEwords and count the occurrences of each unique word. When the fil...

    CSC110 Lab 6 (ALL CODING IN JAVA) Problem: A text file contains a paragraph. You are to read the contents of the file, store the UNIQUEwords and count the occurrences of each unique word. When the file is completely read, write the words and the number of occurrences to a text file. The output should be the words in ALPHABETICAL order along with the number of times they occur and the number of syllables. Then write the following statistics to...

  • How can you solve this problem using if statements? CSCI 206 Lab Date: 27 March 2020...

    How can you solve this problem using if statements? CSCI 206 Lab Date: 27 March 2020 Lab 8 - Coffee Switches Due: 2 April 2020 Please submit your lab on Moodle. Since we are not meeting Friday, March 27, you must fill out your attendance assignment in your lecture section on Moodle. There is now a new category called Friday Attendance. Please go there and do the attendance assignment to be marked for attendance. Notes: . Carefully read and adhere...

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