我如何使用 linux 编写基本脚本? [英] how do I basic script with linux?

查看:32
本文介绍了我如何使用 linux 编写基本脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个命令有什么作用?

!/bin/bash

我的第一个脚本

clear
echo (I don't know what will come after echo , can you help me with that too?)
./hello.shell

推荐答案

#!/bin/bash 被称为 shebang(您错过了开头的 #).它告诉哪个程序将执行您的脚本.

#!/bin/bash is called the shebang (you missed the leading #). It tells which program will execute your script.

clear 用于清屏.

echo 将以下参数输出到标准输出(默认为您的终端).但是您不能用括号将字符串括起来,因为它用于在子 shell 中对命令进行分组.如果你想打印 (...),你也必须使用双引号:

echo outputs following argument to the standard output (your terminal by default). But you must not surround your string with parenthesis as it's used for grouping command in a sub-shell. If you want to print (...), you'll have too use double quotes :

echo "(I don't know what will come after echo , can you help me with that too?)"

./hello.shell 将在您使用 chmod +x hello.shell 授予它执行权限后执行您的脚本.

./hello.shell will execute your script after you gave it execute permissions with chmod +x hello.shell.

请注意,shell 脚本常用的扩展名是 .sh 而不是 .shell.

Note that commonly used extension for a shell script is .sh rather than .shell.

欲了解更多,请尝试这些链接:

For more, try theses links :

http://mywiki.wooledge.org/BashGuide/

http://www.tldp.org/LDP/Bash-Beginners-指南/html/

这篇关于我如何使用 linux 编写基本脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆