我只是想在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
}