[ shell ] — 基础、变量、字符串、数组——1
发布日期:2021-05-15 02:51:52 浏览次数:17 分类:精选文章

本文共 2710 字,大约阅读时间需要 9 分钟。

���������������������������

shell���������linux/unix������������������������������������������������������������������������������shell������������������������

1. shell������������������

shell���������������������������������������������������������������������bin/sh���bin/bash���������#!/bin/bash���������bash���������������������#!/bin/sh���������������/bin/sh������������������������������������������������������������������ Tory ������������������/bin/sh������������

2. shell���������������������

shell������������������������������������.sh���������������������������������������������������������shell������������������������������������������������������.sh������������

3. ������shell���������������

������shell���������������������������������

  • bash test.sh���������bash������������������������������
  • source test.sh������������������������������������������������
  • . test.sh��� ������������������������������
  • /bin/sh test.sh���������/bin/sh���������������������
  • /bin/bash test.sh���������/bin/bash���������������������

4. shell������

���shell������������������������������������������������������������������������������������������������������������ilizor���������������

  • ���������������������������������������ls /etc������������������������������
  • ���������������������readonly myurl���������������������
  • ���������������������unset _val���������������������������������������������

5. shell���������

shell������������������������������������������������������������������������������������������������������������������������������

  • ���������������������������
name=Max
myname1='my name is '$name''
  • ���������������������������
name=Max
yourname="your name is '$name!'"
yourname1="your name is $name!"
  • ������������������
yourmin Iggreen3="your name is '$yourname!'"
������4= "your name is $yourname!"
echo ${������3} $������4
  • ������������������
string="abcd!"
echo ${#string}
  • ���������������������
string="ILoveLJ"
echo ${string:1:4}
  • ���������������
string="ILoveLJ"
echo `expr index "$string" oe`

6. Shell������

������������������������������������������������������������������������������������

  • ������������������������������
# ���������������������������������������������
array=(v0 v1 v2 v3 v4)
# ������������������������������������������
array1=()
# ������������������������������
array2[0]=a0
  • ���������������������
echo ${array[1]} # ���������������������������
echo ${array1[@]} # ������������������������
  • ���������������������
echo ${#array[@]}
echo ${#array[*]}
  • ������������������������������������
echo ${#array[1]}

������������������������������������������shell���������������������������������������������������������������shell������������������������������������������������������������

上一篇:[ shell ] — 注释、运算符、echo、printf、test——2
下一篇:Apache Cordova Android 打包以及模拟器中运行

发表评论

最新留言

感谢大佬
[***.8.128.20]2025年04月28日 21时11分53秒