面试题答案
一键面试str="hello_world_123"
# 截取world部分
world=$(echo $str | cut -d '_' -f 2)
echo "截取的world部分: $world"
# 将123替换为456
new_str=$(echo $str | sed 's/123/456/')
echo "最终的字符串: $new_str"
str="hello_world_123"
# 截取world部分
world=$(echo $str | cut -d '_' -f 2)
echo "截取的world部分: $world"
# 将123替换为456
new_str=$(echo $str | sed 's/123/456/')
echo "最终的字符串: $new_str"