Skip to main content
added 410 characters in body
Source Link
Kusalananda
  • 356.1k
  • 42
  • 737
  • 1.1k

Yes, in this case.

Summary: The hash-bang line (also called "shebang" and other things) is only ever needed if it's in an executable script that is run without explicitly specifying its interpreter (asjust as when executing a binary executable file).

In thisthe case of your code, you're explicitly running the script within the here-document with bash already. There's no need to add the hash-bang as it will be treated as a comment.

InSince the case ofhere-document script seems to want to be executed with the -x option set (judging from #!/bin/bash -x), you will have to use set -x inside the here-document to get the same effect as if running the here-document as its own script, again, because the hash-bang is treated as a comment.

The hash-bang line is used when executing an executable text file. The line tells the system what interpreter to use to execute it, and optionally allows you to specify one argument to that interpreter (-x in your case).

You do need the hash-bang there if you're writing the here-document to a file that will later be used as a script. SuchFor example:

cat >myscript.sh <<<END_OF_SCRIPT #!/bin/bash # contents of script # goes here END_OF_SCRIPT 

Such a file also has to be made executable (chmod +x myscript.sh). But again, if you were to explicitly execute that script with bash (as bash ./myscript or bash -x ./myscript, for example through

$ bash ./myscript.sh 

or whatever

$ bash -x ./myscript.sh 

(or equivalently from within another script), then no hash-bang is needed (and, and the script would not have to be made executable).

It all comes down to how you would want to execute the script.

See also the Wikipedia entry for Shebang.

Yes, in this case.

Summary: The hash-bang line (also called "shebang" and other things) is only ever needed if it's in an executable script that is run without explicitly specifying its interpreter (as when executing a binary executable file).

In this case you're explicitly running the script within the here-document with bash already. There's no need to add the hash-bang as it will be treated as a comment.

In the case of #!/bin/bash -x, you will have to use set -x inside the here-document to get the same effect as running the here-document as its own script, again, because the hash-bang is treated as a comment.

The hash-bang line is used when executing an executable text file. The line tells the system what interpreter to use to execute it, and optionally allows you to specify one argument to that interpreter (-x in your case).

You do need the hash-bang there if you're writing the here-document to a file that will later be used as a script. Such a file also has to be made executable. But again, if you were to explicitly execute that script with bash (as bash ./myscript or bash -x ./myscript or whatever), no hash-bang is needed (and the script would not have to be made executable).

See also the Wikipedia entry for Shebang.

Yes, in this case.

Summary: The hash-bang line (also called "shebang" and other things) is only ever needed if it's in an executable script that is run without explicitly specifying its interpreter (just as when executing a binary executable file).

In the case of your code, you're explicitly running the script within the here-document with bash already. There's no need to add the hash-bang as it will be treated as a comment.

Since the here-document script seems to want to be executed with the -x option set (judging from #!/bin/bash -x), you will have to use set -x inside the here-document to get the same effect as if running the here-document as its own script, again, because the hash-bang is treated as a comment.

The hash-bang line is used when executing an executable text file. The line tells the system what interpreter to use to execute it, and optionally allows you to specify one argument to that interpreter (-x in your case).

You do need the hash-bang there if you're writing the here-document to a file that will later be used as a script. For example:

cat >myscript.sh <<<END_OF_SCRIPT #!/bin/bash # contents of script # goes here END_OF_SCRIPT 

Such a file also has to be made executable (chmod +x myscript.sh). But again, if you were to explicitly execute that script with bash, for example through

$ bash ./myscript.sh 

or

$ bash -x ./myscript.sh 

(or equivalently from within another script) then no hash-bang is needed, and the script would not have to be made executable.

It all comes down to how you would want to execute the script.

See also the Wikipedia entry for Shebang.

deleted 30 characters in body
Source Link
Kusalananda
  • 356.1k
  • 42
  • 737
  • 1.1k

Yes, in this case.

Summary: The hash-bang line (also called "shebang" and other things) is only ever needed if it's in an executable script that is run from the shell without explicitly specifying its interpreter (as when executing a binary executable file).

In this case you're explicitly running the script within the here-document with bash already. There's no need to add the hash-bang as it will be treated as a comment.

In the case of #!/bin/bash -x, you will have to use set -x inside the here-document to get the same effect as running the here-document as its own script, again, because the hash-bang is treated as a comment.

The hash-bang line is used when executing an executable text file from the shell. The line tells the system what interpreter to use to execute it, and optionally allows you to specify one argument to that interpreter (-x in your case).

You do need the hash-bang there if you're writing the here-document to a file that will later be used as a script. Such a file also has to be made executable. But again, if you were to explicitly execute that script with bash (as bash ./myscript or bash -x ./myscript or whatever), no hash-bang is needed (and the script would not have to be made executable).

See also the Wikipedia entry for Shebang.

Yes, in this case.

Summary: The hash-bang line (also called "shebang" and other things) is only ever needed if it's in an executable script that is run from the shell without explicitly specifying its interpreter (as when executing a binary executable file).

In this case you're explicitly running the script within the here-document with bash already. There's no need to add the hash-bang as it will be treated as a comment.

In the case of #!/bin/bash -x, you will have to use set -x inside the here-document to get the same effect as running the here-document as its own script, again, because the hash-bang is treated as a comment.

The hash-bang line is used when executing an executable text file from the shell. The line tells the system what interpreter to use to execute it, and optionally allows you to specify one argument to that interpreter (-x in your case).

You do need the hash-bang there if you're writing the here-document to a file that will later be used as a script. Such a file also has to be made executable. But again, if you were to explicitly execute that script with bash (as bash ./myscript or bash -x ./myscript or whatever), no hash-bang is needed (and the script would not have to be made executable).

See also the Wikipedia entry for Shebang.

Yes, in this case.

Summary: The hash-bang line (also called "shebang" and other things) is only ever needed if it's in an executable script that is run without explicitly specifying its interpreter (as when executing a binary executable file).

In this case you're explicitly running the script within the here-document with bash already. There's no need to add the hash-bang as it will be treated as a comment.

In the case of #!/bin/bash -x, you will have to use set -x inside the here-document to get the same effect as running the here-document as its own script, again, because the hash-bang is treated as a comment.

The hash-bang line is used when executing an executable text file. The line tells the system what interpreter to use to execute it, and optionally allows you to specify one argument to that interpreter (-x in your case).

You do need the hash-bang there if you're writing the here-document to a file that will later be used as a script. Such a file also has to be made executable. But again, if you were to explicitly execute that script with bash (as bash ./myscript or bash -x ./myscript or whatever), no hash-bang is needed (and the script would not have to be made executable).

See also the Wikipedia entry for Shebang.

added 1 character in body
Source Link
Kusalananda
  • 356.1k
  • 42
  • 737
  • 1.1k

Yes, in this case.

Summary: The hash-bang line (also called "shebang" and other things) is only ever needed if it's in an executable script that is run from the shell without explicitly specifying its interpreter (as when executing a binary executable file).

In this case you're explicitly running the script within the here-document with bash already. There's no need to add the hash-bang as it will be treated as a comment.

In the case of #!/bin/bash -x, you will have to use set -x inside the here-document to get the same effect as running the here-document as its own script, again, because the hash-bang is treated as a comment.

The hash-bang line is used when executing an executable text file from the shell. The line tells the shellsystem what interpreter to use to execute it, and optionally allows you to specify one argument to that interpreter (-x in your case).

You do need the hash-bang there if you're writing the here-document to a file that will later be used as a script. Such a file also has to be made executable. But again, if you were to explicitly execute that script with bash (as bash ./myscript or bash -x ./myscript or whatever), no hash-bang is needed (and the script would not have to be made executable).

See also the Wikipedia entry for Shebang.

Yes, in this case.

Summary: The hash-bang line (also called "shebang" and other things) is only ever needed if it's in an executable script that is run from the shell without explicitly specifying its interpreter (as when executing a binary executable file).

In this case you're explicitly running the script within the here-document with bash already. There's no need to add the hash-bang as it will be treated as a comment.

In the case of #!/bin/bash -x, you will have to use set -x inside the here-document to get the same effect as running the here-document as its own script, again, because the hash-bang is treated as a comment.

The hash-bang line is used when executing an executable text file from the shell. The line tells the shell what interpreter to use to execute it, and optionally allows you to specify one argument to that interpreter (-x in your case).

You do need the hash-bang there if you're writing the here-document to a file that will later be used as a script. Such a file also has to be made executable. But again, if you were to explicitly execute that script with bash (as bash ./myscript or bash -x ./myscript or whatever), no hash-bang is needed (and the script would not have to be made executable).

See also the Wikipedia entry for Shebang.

Yes, in this case.

Summary: The hash-bang line (also called "shebang" and other things) is only ever needed if it's in an executable script that is run from the shell without explicitly specifying its interpreter (as when executing a binary executable file).

In this case you're explicitly running the script within the here-document with bash already. There's no need to add the hash-bang as it will be treated as a comment.

In the case of #!/bin/bash -x, you will have to use set -x inside the here-document to get the same effect as running the here-document as its own script, again, because the hash-bang is treated as a comment.

The hash-bang line is used when executing an executable text file from the shell. The line tells the system what interpreter to use to execute it, and optionally allows you to specify one argument to that interpreter (-x in your case).

You do need the hash-bang there if you're writing the here-document to a file that will later be used as a script. Such a file also has to be made executable. But again, if you were to explicitly execute that script with bash (as bash ./myscript or bash -x ./myscript or whatever), no hash-bang is needed (and the script would not have to be made executable).

See also the Wikipedia entry for Shebang.

added 41 characters in body
Source Link
Kusalananda
  • 356.1k
  • 42
  • 737
  • 1.1k
Loading
added 350 characters in body
Source Link
Kusalananda
  • 356.1k
  • 42
  • 737
  • 1.1k
Loading
Source Link
Kusalananda
  • 356.1k
  • 42
  • 737
  • 1.1k
Loading