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 Language Help.

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

Need broader help or resources? Head to Language Help and Tips and Resources. If you are wanting feedback or inspiration for a project, check out Projects.

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 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

2 Likes

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

7 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

1 Like

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:

4 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.

Hey, so on checking, it would appear that islands.txt only contains 17, 26, 204, and not the names of any islands - as a result of a previous exercise, which someone’s already mentioned above.

Because the search being carried out for both -R and -Rl is for ‘Island’ not ‘island’ (case sensitive), nothing will come up. Hope this helps!

I encountered an issue when following the instructions for this grep || exercise 10/12. 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.

I followed the hint given:
grep -R Island

I also got the correct result:
islands.txt:Turks and Caicos Islands
islands.txt:Bermuda Islands
islands.txt:Canary Islands
islands.txt:Cayman Islands
islands.txt:Aegean Islands
islands.txt:Frisian Islands
islands.txt:Andaman Islands
islands.txt:Seychelles Islands

But on the left, under instructions checkbox, it shows X(wrong), instead of correct symbol. Is there a Bug?

Hello, I am new to the forums and still trying to get my feet wet.

There are times that I am using the CLI in the exercises where I lose the starting “$” and the only recourse is to reload the page.

Does anybody else have this problem?

Thanks!

I also am running into the problem with this specific exercise. I run ‘grep -R’ for Q1 in the exercise and it gives me the correct answer. However, on Q2 I am running ‘grep -R1’ and get the seemingly correct answer on the right, but don’t get the checkbox on the left.

wondering if you ever found out the answer?