Exercise 7/13 question 3


#1

i typed in:

cat lakes.txt | sort > sorted -
lakes.txt

after i type this i got a text back with:

bash: lakes.txt: command not found

can anyone help me please thank you.


#2

lakes.txt is indeed not a command and bash tells you so. Did you expect something else to happen? If so what?

Also, is the "-"-character at the end of your first command supposed to have some effect? Why is it there?


#3

did u follow the instruction? it state there need to put "-" in the command line.


#4

https://www.codecademy.com/en/courses/learn-the-command-line/lessons/redirection/exercises/pipes

Do you mean this?
cat lakes.txt | sort > sorted-lakes.txt
That's part of the file name.

As it so happens it is allowed, from sort's manpage:

       With no FILE, or when FILE is -, read standard input.

But it's optional, and I think it should rather be written in this order:
cat lakes.txt | sort - > sorted

But since reading from stdin is common behaviour for that kind of command, I find it a bit peculiar to add it, it might be there for compatibility or something like that.

But better yet is to write:

sort lakes.txt > sorted