shell脚本是一种程序与linux内核的语言:

第一个shell脚本:

#!/bin/bash
echo "cxy"

就是输出cxy

如何执行这个脚本呢:

cd demo                    进入shell脚本的目录
chmod +x./test.sh      给当前脚本授权
./test.sh                    执行当前脚本

 也可以使用source命令来运行

source test.sh

下面的脚本使用 read 命令从 stdin 获取用户输入的内容并赋值给 PERSON 变量,最后在 stdout 上输出:

#!/bin/bash
# Copyright (c) http://c.biancheng.net/shell/

echo "What is your name?"
read PERSON
echo "Hello, $PERSON"
$ chmod +x ./test.sh
$ ./test.sh
What is your name?
mozhiyan
Hello, mozhiyan
$

如果没有虚拟机的可以进:http://www.dooccn.com/shell/ 去练习

相关文章:

  • 2021-09-07
  • 2021-12-07
  • 2021-10-19
  • 2021-11-27
  • 2021-07-18
猜你喜欢
  • 2021-09-28
  • 2021-08-30
  • 2021-08-03
  • 2022-12-23
  • 2022-12-23
  • 2022-01-13
相关资源
相似解决方案