美文网首页
shell语法(不断更新中)

shell语法(不断更新中)

作者: 古寒飞 | 来源:发表于2017-03-02 15:40 被阅读13次

#!/bin/bash

#创建一个数组

array=(
987
876
765
654
543
432
321
)


#读取数组中所有的数据

echo "方法1:${array[*]}"

echo "方法2:${array[@]}"


#读取数组中下标为5的元素

echo "下标为5的元素:${array[5]}"


#获取数组中下标为5的数据长度

echo "$array数组的长度为:${#array[5]}"


#接受用户的输入

read -p "程序到这里并为结束,需要您输入一个名字:" name

echo "$name 早上好!"


#不换行显示

echo -n "第一行"

echo "第二行"


#插入空行

echo "第三行"

echo

echo "第四行"


#显示结果定向到文件内,myfile文件可以不用事先被创建

echo "taytaytay" > myfile


#显示命令执行的结果

echo `date`


=====待补充。。。

相关文章

网友评论

      本文标题:shell语法(不断更新中)

      本文链接:https://www.haomeiwen.com/subject/vjfkgttx.html