How do I execute a bash script in Terminal?

后端 未结 9 2026
無奈伤痛
無奈伤痛 2020-12-12 11:50

I have a bash script like:

#!/bin/bash

echo Hello world!

How do I execute this in Terminal?

相关标签:
9条回答
  • 2020-12-12 12:29

    You could do:
    sh scriptname.sh

    0 讨论(0)
  • 2020-12-12 12:40

    And yet one more way

    . /path/to/script
    

    What is the meaning of the dot?

    0 讨论(0)
  • 2020-12-12 12:42

    Change your directory to where script is located by using cd command

    Then type

    bash program-name.sh
    
    0 讨论(0)
提交回复
热议问题