PG Certificate Course in Data Science, AI & Machine Learning by IIT Roorkee. Apply Now & Get up to Rs. 75,000 OFF! Offer Ends in:Apply Now
If we want to send the output of one program to another, we can use the pipe. A pipe is denoted by
echo command prints on the standard output whatever argument is passed to it.
wc command prints the number of characters, words, and lines out of whatever you type on standard input. Start
wc command, type some text and press
Ctrl+d to end the input:
wc hi how are you [CTRL + d]
2 4 15
wc command also counts new line (\n ) character.
Now, if we want to count the number of words, characters in the output of any program, we can pipe the output in the following way:
echo "Hello, World" | wc
You can also save the results using redirection, in the following way:
echo "Hello, World" | wc > wc_results
Please execute the above command to succeed in the assessment.
Note - Having trouble with the assessment engine? Follow the steps listed here