图片 Linux操作系统Shell基础知识_bbin体育app下载_bbin体育客户端_体育官网~

bbin体育app下载_bbin体育客户端_体育官网~

当前位置:主页 > 电脑教程 > 操作系统 > Linux教程 > >

Linux操作系统Shell基础知识

来源::未知 | 作者:bbin体育app下载_bbin体育客户端_体育官网~ | 本文已影响
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没有jiao换,我们可以进行jiao互,如下:



#!/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


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

bbin体育app下载_bbin体育客户端_体育官网~

热榜阅读TOP

本周TOP10

 Linux系统管理

Linux系统管理

Linux属于多用户多任务的操作系统,可让不同的用户从本地登陆。在网络上则允许用户利用telnet、ssh等方式...