我有一个名为text.txt的文件,其中包含:

id="qwidget_lastsale" class="qwidget-dollar">$2020.22\div

我真的需要从那个文本文件中打印出word 2020.22。
我使用命令:
awk '{print $2}' text.txt | grep 2020.22

但我的输出将打印:
class="qwidget-dollar">$2020.22\dev

我可以使用哪个命令从该字符串中仅打印2020.22?

最佳答案

你想提取美元价值吗?

$ grep -oP '(?<=\$)[0-9.]+' file

关于linux - Linux命令从长字符串中打印一些字符,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/53403928/

10-12 22:41
查看更多