零零社区|百姓的网上家园-互动交流平台!(0.0)=^_^=(00社区)

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
热搜: 活动 交友 discuz

新手学堂:Linux操作系统Shell基础知识

2013-4-5 16:22| 发布者: 123456000000| 查看: 10| 评论: 0

摘要: 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 运行firsts ...

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

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


路过

雷人

握手

鲜花

鸡蛋

相关阅读

发表评论

最新评论

相关分类


Archiver|手机版|小黑屋|00社区

GMT+8, 2023-1-31 10:50 , Processed in 0.042809 second(s), 18 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部