Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
文字列の部分文字列を見つけようとしています。
string がある場合は、stringtry-30/16を取得したいと思い30ます。
try-30/16
30
だから私は次のように書いた:
n=${"'$b'":'-':'/'}
$b は、このコマンドの前に割り当てる変数です。それは次を与える:
代用が悪い。
どうすればそれができますか?
次のこともできます。
[[ $b =~ [^-]+-([0-9]+) ]] && echo "${BASH_REMATCH[1]}"
出力: