热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

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

文章标题:新手学堂:Linux操作系统Shell基础知识。Linux是中国IT实验室的一个技术频道。包含桌面应用,Linux系统管理,内核研究,嵌入式系统和开源等一些基本分类
  1 cat /etc/shells
 
  查看计算机上可用的shell
 
  2 编写shell,保存为firstscript
 
  
 #! /bin/bash

# This is a test.

echo -n Your current directory is:

pwd

echo $HOME

echo 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/sh

echo -n Please input your ID:

read id_var

echo -n Please input your password:

read password

echo User ID = $id_var

echo password = $password

if [ $password = "admin" ]; then

echo "password is right"

else

echo "password is wrong"

fi

 
  同前面的运行,自己测试。
 
推荐阅读
author-avatar
wo1344165221
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有