Linux下 把shell命令写到一个文件里,直接执行,相当于一个批处理文件。
下面是简单的写法:
1、建一个文本文件

2、


OK!
另外:
如果想直接在终端输入test.sh就运行,而不是到当前文件夹,再./test.sh运行要怎么弄呢。
很简单,把这个文件copy到/usr/bin中就行了。

另外: linux给终端添加自定义命令
在文件/root/.bashrc中,添加以下行:
alias mycommand = "cd /root"
在终端直接执行mycommand就会执行cd /root