Linux中国 Linux中国门户站!
设为主页 设为主页
收藏本站 收藏本站
 
当前位置 :首页 ->Linux技术 ->网络应用 ->正文

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

来源: 作者:Webmaster 时间:2008-04-24 点击: [收藏] [投稿]

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系统设置编译器路径的几种方法介绍   下一篇:命令行中“\”和“--”符号所代表的含义

文章评论】 【收藏本文】 【推荐好友】 【打印本文】 【我要投稿】 【论坛讨论
更多相关文章
Power by linux-cn.com 粤ICP备05006655号