Bash commandline firstline=$(head -n 1 source/ final project

Hi I am currently working on the bash command line project and they started talking about the and I am confused as to what to do. Then in the hint I am seeing the line
firstline=$(head -n 1 source/
So I know it is a delcared variable being assigned a value but can anyone explain this to included the and what does it do? I am confused because it isn’t covered in the course inclusive of the beginners course of learn command line

The file is just a markdown (.md) text file. It should be kept up to date by the code author(s) and just details changes and updates to the code in chronological order (have a little web search if you’re curious, not everyone bothers with them). If I remember rightly in this example the file is a very simple one line job and all you need to do is select part of this first-line in your script.

Not sure if you had problems with the file or the commands. If the commands are also an issue then read on…
If you’re likely to be using bash often then it might be worth getting into the habit of looking at the man pages for such commands either online or in the shell.

The head command is similar in nature to cat but with an aim to print out only the first part of a file. Using the -n flag specifies the number of lines to print.

Best way to be sure is to test it yourself and play around with it a little. Perhaps consider trying tail while you’re at it…

Command substitution is the name of the $( command ) syntax you see-

* I bumped this into get-help: command line

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