<RecordId>12345</RecordId> 只想提取12345 1.grep 速度一般 type myXmlFile.xml|grep -oE "<RecordId>(.*)</RecordId>"|sed "s/<RecordId>//g;s/</RecordId>//g" type myXmlFile.xml|d:msysopt oolsingrep -oP "<RecordId>Kw+" type myXmlFile.xml|d:msysopt oolsingrep -oP "<RecordId>Kw+(?=</RecordId>)" 零宽断言 type myXmlFile.xml|d:msysopt oolsingrep -oP "(?<=<RecordId>).*(?=</RecordId>)" 后发断言 先行断言 2.sift 速度较快 type myXmlFile.xml|sift "<RecordId>(.*)</RecordId>" --replace "$1" 3.ripgrep 速度非常快 type myXmlFile.xml|rg "<RecordId>(.*)</RecordId>" -r "$1"