Bash / command line

I am doing the project for learning Bash.

The output of this command
head -n1 ./source/
was to go into the variable firstline, so I wrote this.
firstline=(head -n1 ./source/
The correct answer is
firstline=$(head -n1 ./source/

  1. I don’t understand why you would use the $ there when you are defining the variable?

I also had tried piping the output
head -n1 ./source/ | firstline
2) I am not sure how to have correctly written that command


You’re not just setting a variable you are also running a command. Those are two separate problems.
If you don’t treat it like one blob and instead look at each action individually and how each method would need to fit with other parts, then you stand a chance.

What would you put on the right side of a pipe?
What would you put on the right side of = in assignment?

If you decide what you need and look at what you have, that tells you something about what you need to do to cross that bridge.

I have this and need that. Is there such an operation?

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.