Question

Introduction to Linux/Unix 5. Print to the terminal the contents of foo.txt, selecting only those lines...

Introduction to Linux/Unix

5. Print to the terminal the contents of foo.txt, selecting only those lines with the word "foo" as a whole word
In other words, "foo" must NOT appear as part of another string, like "foobbbbbbbb".
There is an option for grep that tells it to only match the string when it appears as a word, not as part of a bigger string
Check the man page for grep to find this option
Don't call the man page from within your shell script.

What's the command?

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

Command \;"cat" \;is \;used \;to \;display \;the \;content of \;a \;file \;in \;terminal.\;

Command \;"grep" \;is \;used \;to \;filter\;the \;content.

\;Option \;'w' \;of \;grep \;is \;used \;to \;match \;whole \;word.\;

\color{red}\underline{Command:}

cat foo.txt | grep -w "foo"

cat \;foo.txt \;| \;grep \;-w \;"foo"\;

Add a comment
Know the answer?
Add Answer to:
Introduction to Linux/Unix 5. Print to the terminal the contents of foo.txt, selecting only those lines...
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
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
ADVERTISEMENT