且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

ubuntu运行文本文件作为命令

更新时间:1970-01-01 07:55:42

您可以使用这些命令创建一个shell脚本,然后 chmod + x< scriptname.sh> ,然后通过

运行它。

  ./ scriptname.sh 
$ p>

写一个bash脚本非常简单



Mockup sh文件:

 #!/ bin / sh 
sudo command1
sudo command2



sudo commandn


If I have a text file with a seperate command on each line how would I make terminal run each line as a command? I just dont want to have to copy and paste 1 line at a time. It doesnt HAVE to be a text file...It can be any kind of file that will work.

example .txt

sudo command 1
sudo command 2
sudo command 3

you can make a shell script with those commands, and then chmod +x <scriptname.sh>, and then just run it by

./scriptname.sh

Its very simple to write a bash script

Mockup sh file:

#!/bin/sh
sudo command1
sudo command2 
.
.
.
sudo commandn