加入收藏 | 设为首页 | 会员中心 | 我要投稿 银川站长网 (https://www.0951zz.com/)- 云通信、基础存储、云上网络、机器学习、视觉智能!
当前位置: 首页 > 服务器 > 搭建环境 > Linux > 正文

Linux操作系统Shell基础常识

发布时间:2023-06-17 13:23:04 所属栏目:Linux 来源:
导读:Shell基础知识:1、cat /etc/shells查看计算机上可用的shell2、编写shell,保存为firstscript#! /bin/bash# This is a test.echo -n Your current directory is:pwdecho $HOMEecho Your current directory is:pwd#EN

Shell基础知识:

1、cat /etc/shells

查看计算机上可用的shell

2、编写shell,保存为firstscript

#! /bin/bash# This is a test.echo -n Your current directory is:pwdecho $HOMEecho Your current directory is:pwd#END.

3、运行firstscript

$ /bin/bash firstscript

如果找不到文件 使用pwd查看当前目录

$ /bin/bash pwd/firstscript

可见当前运行结果。

4、可以修改firstscript为执行

$chmod a+x firstscript

此时输入$ ./firstscript即可

上面的shell没有交换,我们可以进行交互,如下:

#!/bin/shecho -n Please input your ID:read id_varecho -n Please input your password:read passwordecho User ID = $id_varecho password = $passwordif [ $password = "admin" ]; thenecho "password is right"elseecho "password is wrong"fi

同前面的运行,自己测试。

命令行中“”和“--”符号所代表的含义

如果在行末,是说明本行还未结束,下面一行和本行是一起的意思.

-- 就是选项的开始,一般一个字母的选项用 - 开头,多个字母的就用 -- 开头.

“”后如果是回车,不换行的话可能省略;但要是其它字符,就不能省略。

“”告诉系统后面跟着的字符为原意,不是命令,比如有个文件名中带有空格,就要在空格前加一个“”。

(编辑:银川站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!