我的 sed 很接近...但不完全在那里,你能帮忙吗? [英] my sed is close... but not quite there, can you help please?

查看:45
本文介绍了我的 sed 很接近...但不完全在那里,你能帮忙吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只想打印符合条件的行:worde:"和wordo;"我走到这一步了:

I want to print only the lines that meet the criteria : "worde:" and "wordo;" I got this far:

sed -n '/\([a-z]*\)\1e:\1o;/p;'  

但这并不完全有效.有人可以完善它并确切地告诉我它的固定版本/我的有什么问题吗?(请注意从来没有大写字母,因此我没有费心将其包含在我的初始字符范围内)

But it doesn't quite work. Can someone please perfect it and tell me exactly how its a fixed version/what was wrong with mine? (Please note there are no capital letters ever, hence why I didn't bother including that within my initial character range)

谢谢堆,

推荐答案

这将处理worde:wordo;"的行(字之间没有)出现:

This will handle lines where "worde:wordo;" (nothing between the words) appears:

sed -n '/\([a-z]*\)e:\1o;/p;'

如果您需要在单词之间允许字符,您需要这样的东西:

If you need to allow for characters BETWEEN the words, you'll need something like this:

sed -n '/\([a-z]*\)e:.*\1o;/p;'

这篇关于我的 sed 很接近...但不完全在那里,你能帮忙吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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