shell 如何将一行数据中,将含有指定字符串AAA的后面第X个字符提取出来? 20
请教一下,shell如何将一行数据中,将含有指定字符串AAA的后面第X个字符提取出来?比如原始数据是:aa<name="level"/><value="a"/>sdwe<...
请教一下, shell 如何将一行数据中,将含有指定字符串AAA的后面第X个字符提取出来?
比如原始数据是:
aa<name="level"/><value="a"/>sdwe<name="score"/><value="99"/>afdfdasd
aa<name="level"/><value="c"/>sdwe<name="score"/><value="40"/>afdfdasd
aa<name="level"/><value="s"/>sdwe<name="score"/><value="100"/>afdfdasd
提取score后面的值99,40,100这些,输出格式是:
score 99
score 40
score 100
请问该如何实现呢?
需要在linux里面用shell脚本实现~~~ 展开
比如原始数据是:
aa<name="level"/><value="a"/>sdwe<name="score"/><value="99"/>afdfdasd
aa<name="level"/><value="c"/>sdwe<name="score"/><value="40"/>afdfdasd
aa<name="level"/><value="s"/>sdwe<name="score"/><value="100"/>afdfdasd
提取score后面的值99,40,100这些,输出格式是:
score 99
score 40
score 100
请问该如何实现呢?
需要在linux里面用shell脚本实现~~~ 展开
展开全部
假设你的数据在A列,且从A1开始
B1="score "&MID(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"""",""),"score/><value=","座"),"/>afdfdasd","宋"),FIND("座",SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"""",""),"score/><value=","座"),"/>afdfdasd","宋"))+1,FIND("宋",SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"""",""),"score/><value=","座"),"/>afdfdasd","宋"))-FIND("座",SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"""",""),"score/><value=","座"),"/>afdfdasd","宋"))-1)
有点长,经过2个替换关键字,然后查找2个关键字之间的位置就是 数据。
B1="score "&MID(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"""",""),"score/><value=","座"),"/>afdfdasd","宋"),FIND("座",SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"""",""),"score/><value=","座"),"/>afdfdasd","宋"))+1,FIND("宋",SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"""",""),"score/><value=","座"),"/>afdfdasd","宋"))-FIND("座",SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"""",""),"score/><value=","座"),"/>afdfdasd","宋"))-1)
有点长,经过2个替换关键字,然后查找2个关键字之间的位置就是 数据。
追问
需要在linux里面用shell脚本实现~~~怎么可以做到呢?
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |