FAQ: Redirection - grep II

This community-built FAQ covers the “grep II” exercise from the lesson “Redirection”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Web Development

Learn the Command Line

FAQs on the exercise grep II

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!
You can also find further discussion and get answers to your questions over in #get-help.

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head to #get-help and #community:tips-and-resources. If you are wanting feedback or inspiration for a project, check out #project.

Looking for motivation to keep learning? Join our wider discussions in #community

Learn more about how to use this guide.

Found a bug? Report it online, or post in #community:Codecademy-Bug-Reporting

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

I encountered an issue when following the instructions for this exercise. Instruction #1 reads:

  1. Use grep search through the working directory ( /home/ccuser/workspace/geography ) for anything that matches Island . We want the matching filenames and lines.

Problem is that doesn’t work and it prompts you to use Arctic instead, which works. Why is this a case? is it a bug?

4 Likes

HI I used the same grep function but it outputted blank on the second line so what do we do to get it to see if its successful?
I tried something like grep -R Arctic /home/ccuser/workspace/geography | sort > burned.txt
then I typed cat burned.txt
but it outputted blank

3 Likes

I don’t get any output? Is there a bug?

6 Likes

Answer to question 1: grep -R Island /home/ccuser/workspace/geography

Answer to question 2: grep -Rl Island /home/ccuser/workspace/geography

1 Like

Same problem for me, and the same happens on my Terminal. It seems like it works, but no output is returned.

3 Likes

Same problem for me:

grep -R Island grep -R Island
grep -R Island /home/ccuser/workspace/geography grep -R1 Island /home/ccuser/workspace/geography
$

2 Likes

I looked in islands.txt:

cat islands.txt
17 26 204

I was mistakenly using R1 when I should have been using Rl i.e. lower case L. The command did not find ant results with R or -R. But I have passed on to next.

1 Like

I think there’s a bug on this lesson ( snow to rain lesson ). Changing instances of snow to rain works (the results are printed automatically without cat), but when cat is used, all the instances of rain have reverted back to snow

I know it’s a little late but I had the same problem and found that none of the files contained “Island” so nothing was output. I replaced “Island” with “Ocean” then it printed out all the lines with “Ocean”

3 Likes

Is it necessary to use uppercase -R ?
because in the lesson lowercase -r works just fine

You’d best check the man page for your version of grep but on the version I have to hand GNU grep 3.6 the difference is that -R follows symbolic links (in a very simple way you can think of them like shortcuts in windows, web search would explain difference) whereas -r does not follow symlinks. For these examples no it doesn’t matter but when in doubt use man grep and check what options you have.

Edit: Lesson seems to use GNU 3.1, try grep --help since man isn’t immediately available in this lesson.

2 Likes

The funny thing is the reason there’s no matches for Island is because in an earlier exercise (the one about piping) you clobber islands.txt with the output from wc . Think these lessons needs some better QA :slight_smile:

3 Likes

I haven’t tried out the lowercase R thing myself but in my case a common error I was making was “using the wrong case”. Whether it’s A for Arctic or I for Island (in my case) or -R function, I used uppercase.

Same thing for me. I’m not getting any output.