I agree with C and E.
C - The shebang does define the path (and if you choose, optional arguments) to the interpreter to run the script.
E - It is true that if you place a #, it is ignored by the interpreter. However, before the interpretation takes place, something else happens before that.
"The unix kernel's program loader is responsible for doing this. When exec() is called, it asks the kernel to load the program from the file at its argument. It will then check the first 16 bits of the file to see what executable format it has. If it finds that these bits are #! it will use the rest of the first line of the file to find which program it should launch, and it provides the name of the file it was trying to launch (the script) as the last argument to the interpreter program.
The interpreter then runs as normal, and treats the #! as a comment line."
https://stackoverflow.com/questions/3009192/how-does-the-shebang-work
The question asks "What is true regarding the statement beginning with #! ..."
E is incorrect, as the statement itself is not a comment ignored by the script interpreter!
B. it triggers the installation of the script"™s interpreter.
C. It specifies the path and the arguments of the interpreter used to run the script.
... are the correct answers here
The first line of the script should include a path to the Bash shell executable. The #! tells the system that this first line is intended to provide this path. Typically a pound sign # character is used to comment a line, but when placed at the beginning of the first line and followed by an exclamation mark ! character, it is used to tell the system which executable to use to run the program.
So I think the correct answers are B & C.
The #! (shebang) line is indeed not a comment; it is used to specify the path to the interpreter that should be used to execute the script. So, option E is incorrect in this context. The correct options are:
B. It triggers the installation of the script's interpreter.
C. It specifies the path and the arguments of the interpreter used to run the script.
"The first line is the shebang and defines what program is going to interpret the script:
#!/bin/bash. Curiously enough, that program is bash itself."
https://learning.lpi.org/en/learning-materials/102-500/105/105.1/105.1_03/
A - Is WRONG since the exlamation mark wont prevent the script from being executed
B - Is WRONG since it wont trigger the installation of the interpreter
C - It is CORRECT since the shebang specifies the path of the interpreter and the arguments used (the script will be passed implicitly as first argument and you can specify arguments yourself)
D - It is WRONG since it does not define the encoding
E - It is CORRECT. The selected interpreter (e.g. bash, python) will ignore that line and treat is as a comment, it will not get ignored by the kernel when you execute the script, but the interpreter itself will ignore it
B is true, even though is wrongly redacted: instead of "installation" it should be "initialization"
C is true, actually redundant with B.
E is not true becuase yes, all lines beginning # are considered comments AFTER that initial #!
https://learning.lpi.org/en/learning-materials/102-500/105/105.2/105.2_01/
"the first line should be #!/bin/bash. By indicating this line, the interpreter for all the instructions in the file will be /bin/bash. Except for the first line, all other lines starting with the hash character # will be ignored"
"What is true regarding the statement beginning with #! that is found in the first line of script? (Choose two.)"
Everyone seems to agree that C is correct.
It can't be D, it doesn't have anything to do with the character encoding.
A is also out, because the shebang doesn't prevent the script from being executed.
E is completely wrong. Not only is the statement sarting with #! in the first line not ignored by the script interpreter, it's what informs the system that the file is actually a script and what interpreter it should use for the script!
B isn't quite right because it doesn't trigger the installation of the script's interpreter (it actually triggers the running of the script interpreter), but it's the most-correct answer of the options listed.
"How an interpreter reads a script file varies and there are distinct ways of doing so in a Bash shell session, but the default interpreter for a script file will be the one indicated in the first line of the script, just after the characters #! (known as shebang). In a script with instructions for the Bash shell, the first line should be #!/bin/bash. By indicating this line, the interpreter for all the instructions in the file will be /bin/bash. Except for the first line, all other lines starting with the hash character # will be ignored, so they can be used to place reminders and comments."
{source: LPIC-1 (102) (Version 5.0), page 88}
E is wrong: the first line -ONLY THE FIRST LINE- expect a hash bang sign (also called "shebang") to tell wich kind of shell we'll intend to use and its path.
Absolutely it is NOT a comment.
So C for sure.
B is correct for the same, because the #! in the first line trigger the script interpreter,
the word "installation" is ambiguous, maybe a trick or a type mistake.
I would go for BC in the exam
here is snippet... Except for the first line, all other lines starting with the hash character # will be ignored, so they can be used to place reminders and comments. Blank lines are also ignored..
This means #! is exempted from the rule and hence BC is answer for sure...i cannot see how E can be right at all as questions clearly says the FIRST LINE ONLY it did NOT mention any other lines
Read here: https://learning.lpi.org/en/learning-materials/102-500/105/105.2/105.2_01/#:~:text=the%20default%20interpreter,are%20also%20ignored.
https://en.wikipedia.org/wiki/Shebang_(Unix)
The shebang line is usually ignored by the interpreter, because the "#" character is a comment marker in many scripting languages; some language interpreters that do not use the hash mark to begin comments still may ignore the shebang line in recognition of its purpose
This question is poorly worded. LPIC is placing emphasis on the # comment as well. Changing my answer to C and E.
https://learning.lpi.org/en/learning-materials/102-500/105/105.2/105.2_01/#:~:text=the%20default%20interpreter,are%20also%20ignored.
I think U read it WRONG...here is snippet... Except for the first line, all other lines starting with the hash character # will be ignored, so they can be used to place reminders and comments. Blank lines are also ignored..
This means #! is exempted from the rule and hence BC is answer for sure...i cannot see how E can be right at all as questions clearly says the FIRST LINE ONLY it did NOT mention any other lines
It's B and C, the reason is #! is the shebang, so if you want to ignore it you need to use just # that's why it is not the C, just after the characters #! (known as shebang). In a script with
instructions for the Bash shell, the first line should be #!/bin/bash. By indicating this line, the
interpreter for all the instructions in the file will be /bin/bash. Except for the first line, all other lines starting with the hash character # will be ignored, so they can be used to place reminders and comments. Blank lines are also ignored.
#!/bin/bash
# A very simple script
While it formally looks like a comment, the fact that it's the very first two bytes of a file marks the whole file as a text file and as a script. The script will be passed to the executable mentioned on the first line after the shebang.
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
CuriousLinuxCat
Highly Voted 3 years, 3 months agofeidhlimx
Highly Voted 2 years, 6 months agosnorbis
1 week, 3 days agoSeifoto
Most Recent 5 months, 3 weeks agoAbbribas
10 months, 2 weeks agoaciko11
1 year, 4 months agoblk_542
1 year, 5 months agoAdam_H
1 year, 10 months agoAdam_H
1 year, 10 months agoklever
1 year, 10 months agoamindiashvili
2 years, 6 months agolucaverce
2 years, 6 months agoTedM
2 years, 7 months agoLazylinux
2 years, 7 months agoalitosdavila
2 years, 8 months ago[Removed]
2 years, 8 months ago[Removed]
2 years, 8 months agoLazylinux
2 years, 7 months agomarenco
2 years, 8 months agolbellic
2 years, 8 months agoRobert12
2 years, 9 months ago