溫馨提示×

shell怎么查找字符串位置

小億
539
2024-03-26 10:09:41
欄目: 編程語言

在shell中查找字符串位置可以使用expr命令結合index函數來實現。以下是一個示例:

string="hello world"
substring="world"

position=$(expr index "$string" "$substring")
echo "Substring '$substring' found at position $position"

在這個示例中,string是要查找的字符串,substring是要查找的子字符串。expr index命令會返回子字符串在字符串中第一次出現的位置。

0
亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女