【运维】shell基础指令学习
发布时间:2020-12-15 19:58:05 所属栏目:安全 来源:网络整理
导读:【运维】shell学习笔记 目录 运维shell学习笔记 目录 Shell学习的重要性 常用shell基础指令 功能1编辑脚本执行脚本 功能2 获取用户输入 功能三 变量赋值 未完待续 学习地址: Shell学习的重要性 常用shell基础指令 功能1:编辑脚本,执行脚本 编辑脚本 (tex
【运维】shell学习笔记目录
学习地址: Shell学习的重要性常用shell基础指令功能1:编辑脚本,执行脚本
(text )
#! bin/bash
# “#!” 是一个约定的标记,它告诉系统这个脚本需要什么解释器来执行,即使用哪一种Shell。echo命令用于向窗口输出文本。
脚本文件 以 .sh 结尾
chmod +x root/Documents/test.sh # 使脚本具有执行权限
root/Documents/test.sh # 执行脚本文件
功能2: 获取用户输入
Demo #! bin/bash
# Author :Coco
echo "What's your name?"
read PERSON
echo "My name is $PERSON"
然后脚本激活和执行操作同上 功能三: 变量赋值
#! bin/bash
# Author :Coco
url=http://c.biancheng.net
echo $url
name='C语言中文网'
echo $name
author="严长生"
echo $author
#! bin/bash
skill="Java"
echo "I am good at ${skill}Script"
另外: 当输出的数据中有变量传值得现象的时候,最好用双引号,这样便于解析器进行解析。不然用单引号的时候,就会原样输出,包括$和{ },很丑。
demo cat test.sh
[root@localhost Documents]# test=$(cat test.sh)
[root@localhost Documents]# echo $test
# ! /bin/bash
# Author : mozhiyan
# Copyright (c) http:
# Script follows here: echo "hello world!" name="Coco" echo "hello,$name"
unset 变量名
未完待续 … …(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |