sed/awk截取字符串
<table><tr><td>Password:</td><td>123456</td></tr><tr><td>Hash:</td><td>44efce164ab921...
<table><tr><td>Password:</td><td>123456</td></tr><tr><td>Hash:</td><td>44efce164ab921caaad3b435b5140</td></tr></table> </div>
,想截取44efce164ab921caaad3b435b5140,求命令 展开
,想截取44efce164ab921caaad3b435b5140,求命令 展开
展开全部
[flycat]$cat file
<table><tr><td>Password:</td><td>123456</td></tr><tr><td>Hash:</td><td>44efce164ab921caaad3b435b5140</td></tr></table></div>
[flycat]$cat file | sed 's/^<table>.*<td>//' | awk -F"<" '{print $1}'
44efce164ab921caaad3b435b5140
附送你2个:
cat file | sed 's/^<table>.*<td>//' | sed -r 's/<\/td.*$//'
cat file | awk -F"</td>" '{print $4}'|cut -c 5-
<table><tr><td>Password:</td><td>123456</td></tr><tr><td>Hash:</td><td>44efce164ab921caaad3b435b5140</td></tr></table></div>
[flycat]$cat file | sed 's/^<table>.*<td>//' | awk -F"<" '{print $1}'
44efce164ab921caaad3b435b5140
附送你2个:
cat file | sed 's/^<table>.*<td>//' | sed -r 's/<\/td.*$//'
cat file | awk -F"</td>" '{print $4}'|cut -c 5-
展开全部
我给你个思路吧,试一下下边的shell脚本
#!/bin/bash
echo "<table><tr><td>Password:</td><td>123456</td></tr><tr><td>Hash:</td><td>44efce164ab921caaad3b435b5140</td></tr></table>" | awk '
BEGIN{
FS="</*td>"
RS="</*tr>"
}
{
print "1 - " $1
print "2 - " $2
print "3 - " $3
print "4 - " $4
}'
#!/bin/bash
echo "<table><tr><td>Password:</td><td>123456</td></tr><tr><td>Hash:</td><td>44efce164ab921caaad3b435b5140</td></tr></table>" | awk '
BEGIN{
FS="</*td>"
RS="</*tr>"
}
{
print "1 - " $1
print "2 - " $2
print "3 - " $3
print "4 - " $4
}'
追问
$3结果是这个44efce164ab921caaad3b435b5140,怎么去掉后面的...
追答
不可能,我这里执行后是这个结果:
1 -
2 -
3 -
4 -
1 -
2 - Password:
3 -
4 - 123456
1 -
2 -
3 -
4 -
1 -
2 - Hash:
3 -
4 - 44efce164ab921caaad3b435b5140
1 -
2 -
3 -
4 -
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询