Redirection and Pipelines -> 3. Redirecting Output with >> Error?

Instruction No 1:
Append the first row of any of the files in rg_data to a new file called math_dataset in your home directory.

The provided answer is:
head -n 1 /home/dq/rg_data/Computers\ &\ Mathematics >>math_dataset

I guess that there is an error here. The correct answer should be:
head -n 1 /home/dq/rg_data/* >>math_dataset

Or, Instruction No 1 should be:
Append the first row of “Computers & Mathematics” file in rg_data to a new file called math_dataset in your home directory.

Am I right or am I missing something. Help?

1 Like

Hey, Mirko.

“Any” here means any one of the files, not all of them.

1 Like

Ah, ok.

So, If I understand correctly, for the correct answer, it is not necessary to use “Computers & Mathematics” it could be any of them in the directory, for example, “Education” or “Health”?

Precisely! “The” given answer is really just “an” answer.

Thanks for raise this question, I got confused as well and now it is solved.

2 Likes

I was hung up on this too. I think it’s probably a good idea to amend the screen to say “any one of the files” for clarification. I ended up looking at the answer to pass the screen and spent time re-reading the previous screen as well as this one to see if there was anything to indicate that the Computers file was the “right” answer.

2 Likes

I just got stuck on this as well. I agree with @sean.d.workman that “any one of the files” would help clarify the assignment. Thanks @Bruno for clarifying it here!

1 Like