我只想匹配 Bash 脚本中的一些文本。我试过使用 sed 但我似乎无法让它只输出匹配而不是用某些东西替换它。
echo -E "TestT100String" | sed 's/[0-9]+/dontReplace/g'
哪个会输出TestTdontReplaceString
。
这不是我想要的,我希望它输出100
.
理想情况下,它将所有匹配项放在一个数组中。
编辑:
文本输入以字符串形式出现:
newName()
{
#Get input from function
newNameTXT="$1"
if [[ $newNameTXT ]]; then
#Use code that im working on now, using the $newNameTXT string.
fi
}