您现在的位置: 电脑知识网 >> 电脑系统 >> Linux FreeBSD >> 堂:Linux操作系统Shell基础知识

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

 2008-3-19 8:23:04 来源:PC235.COM 您有问题?请联系我们
关 键 词:堂:Linux操作系统Shell基础知识

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

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

堂:Linux操作系统Shell基础知识文章结束

更多内容请看 电脑系统 > > Linux FreeBSD专题
  • 上一个文章:

  • 下一个文章:
  • 【最新推荐】
    电脑知识学习
    【频道更新】
    【相关文章】
    本站郑重声明:所载文章、数据仅供参考,使用前请核实,风险自负。
    Copyright ©2007-2008 电脑知识网 All Rights Reserved 版权所有 复制必究