在同一条线上两个字符串之间打印文本 [英] Print text between two strings on the same line

查看:102
本文介绍了在同一条线上两个字符串之间打印文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找一个灵时间,一直没能找到工作的答案我的问题。

我从 sed的'162!D'skinlist.html ,其中包含了文本中提取的HTML文件一行

< A HREF =/护肤/矮红胡子-734 /称号=矮红胡子方式>

我想提取文本矮红胡子,但该文本是模块化的(可以改变),所以我想提取<$ C $之间的文本C>标题=和

我不能,因为我的生活,找出如何做到这一点。


解决方案

 的awk'NR == 162 {$打印4}'FS =''skinlist.html


  • 设置字段分隔符

  • 只打印行162

  • 印刷领域4

I've been searching for a ling time, and have not been able to find a working answer for my problem.

I have a line from an HTML file extracted with sed '162!d' skinlist.html, which contains the text

<a href="/skin/dwarf-red-beard-734/" title="Dwarf Red Beard">.

I want to extract the text Dwarf Red Beard, but that text is modular (can be changed), so I would like to extract the text between title=" and ".

I cannot, for the life of me, figure out how to do this.

解决方案

awk 'NR==162 {print $4}' FS='"' skinlist.html

  • set field separator to "
  • print only line 162
  • print field 4

这篇关于在同一条线上两个字符串之间打印文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆