我必须阅读具有html内容的txt文件。匹配字符串patten,如果匹配,则获取文本文件中下一行的所有内容。
混淆了要使用的shell命令。使用EXEC,CAT ..找到了一些示例代码,但无法获得我的预期输出。
这是webdata.txt中的内容
<li id="rowForcustomfield_10003" class="item">
<div class="wrap">
<strong title="Name" class="name">Name:</strong>
<div id="customfield_10003-val" class="value type-cascadingselect" data-fieldtype=
"cascadingselect" data-fieldtypecompletekey="com.atlassian.jira.plugin.system.
customfieldtypes:cascadingselect"> JAMES - WELLIS </div>
</div>
</li>
如果字符串“名称”匹配,那么我需要保存“ JAMES-WELLIS”
文本文件中的几个名称也显示如下,带有多个空格和换行符。
<div class="wrap">
<strong title="Architecture/Derivate" class="name">Name:</strong>
<div id="customfield_10003-val" class="value type-cascadingselect" data-fieldtype="cascadingselect" data-fieldtypecompletekey="com.atlassian.jira.plugin.system.customfieldtypes:cascadingselect">
GREG
R GEORGE
</div>
</div>
这是我找到的示例代码
do
if [[ $(grep ">Name:" $line) ]];
then
echo "$line + 1" # get next line data from webdata.txt
fi
done < webdata.txt