should result in the script displaying 4 since there are four words in the invocation

Write a script that lets users specify echo and wc command sequences, allowing them to use the word "pipe" to represent a pipe symbol. So input like:
echo this is a test pipe wc -w
should result in the script displaying 4 since there are four words in the invocation.

There are various ways to solve this with loops, but the easiest and fastest solution is simply to use the sed command to replace pipe with the pipe symbol. But students need to be careful that they don't get overzealous and change words like "repiped", hence the regular expression:

newcmd=$( echo $@ | sed 's/[^a-zA-Z0-9]pipe[^a-zA-Z0-9]/ | /g' )
eval $newcmd

Computer Science & Information Technology

You might also like to view...

An alternative to fans and heat sinks is

A) An open case design B) A liquid cooled system C) Smaller CPUs D) A turbine

Computer Science & Information Technology

Clip art that is destined for the Web is typically saved in the ____ format.

a. PNG b. GIF c. JPG d. All of the above

Computer Science & Information Technology