shell如何提取字符串中的一部分

 1 #!/bin/bash
 2 function get_string_part()
 3 {
 4 #$1 string, $2 splitor, $3 part
 5     if [ "$2" == "\t" ];then
 6         echo $"$1" | cut -f $3 | xargs echo
 7     else
 8         echo $"$1" | cut -d $2 -f $3 | xargs echo
 9     fi
10 }

 

posted @ 2022-08-24 15:41  huorexiaji  阅读(181)  评论(0)    收藏  举报