Pipe command

in this redirection section the following command displays wc of volcanoes and replace it to island text

cat volcanoes.txt | wc | cat > islands.txt

but nothing happens when i remove cat

cat volcanoes.txt | wc | >> slands.txt
ideally it should have added wc of volcanoes to island.txt
Any solutions why?

https://www.codecademy.com/courses/learn-the-command-line/lessons/redirection/exercises/directing-stdin?action=resume_content_item

Hello :slight_smile:

You overcomplicated this a bit.

This is output of cat volcanoes.txt | wc:

    17    26    204

and you want to add this output to the end of the file islands.txt. But pipe operator is not needed to do that, just redirect the standard output:

cat volcanoes.txt | wc >> islands.txt

We use pipe in bash to serve output of one process as an input for the second process. >> is just a redirection operator.

1 Like