Regex 使用shell脚本在字符串模式后查找文件中的字符串
我的输出文件有4行Regex 使用shell脚本在字符串模式后查找文件中的字符串,regex,shell,Regex,Shell,我的输出文件有4行 storefront/storefront.war/location/header info.jsp:30: storefront/storefront.war/location/header info.jsp:31: storefront/storefront.war/location/header info.jsp:33:|| storefront/storefront.war/location/header info.jsp:35:您可以尝试使用grep: grep -
storefront/storefront.war/location/header info.jsp:30:
storefront/storefront.war/location/header info.jsp:31:
storefront/storefront.war/location/header info.jsp:33:||
storefront/storefront.war/location/header info.jsp:35:您可以尝试使用grep:
grep -Po '\sid="\K[^"]*' file
命令:
sed -r 's/(^.*id=")([^"]+)(.*$)/\2/g' < file.txt
sdlcb@Goofy-Gen:~/AMD$ sed -r 's/(^.*id=")([^"]+)(.*$)/\2/g' < ff.txt
welcomeConfigValue
selected-location
headRestPhone
location-show
sed-r的/(^.*id=“)([^”]+)(.*$)/\2/g'
输出:
sed -r 's/(^.*id=")([^"]+)(.*$)/\2/g' < file.txt
sdlcb@Goofy-Gen:~/AMD$ sed -r 's/(^.*id=")([^"]+)(.*$)/\2/g' < ff.txt
welcomeConfigValue
selected-location
headRestPhone
location-show
sdlcb@Goofy-Gen:~/AMD$sed-r's/(^.*id=“)([^”]+)(.*$)/\2/g'
在这里,我们使用“(“&”)”将模式分为3组。第一组包含从行首到“id=”包括的所有字符。第二组包含“s”之间的字符(即“id=”和对之间的字符)。第三组包含到行尾的剩余字符。然后,我们只需避免第1和第3种模式 MissesheadRestName
tr”“”\n“