我有一堆文件以JSON开头之前的随机文本开头,如下所示:
//full screen:
var narrow = new ScrollMagic.Scene({
triggerElement: '#projects',
offset: -10,
triggerHook: 0,
pushFollowers: false
})
//half size screen:
var wide = new ScrollMagic.Scene({
triggerElement: '#secondary_nav',
offset: 0,
triggerHook: 0,
pushFollowers: false
})
//enquire.js:
enquire.register("screen and (max-width:980px)", {
setup: function() {
narrow.setPin('#secondary_nav ul').addIndicators().addTo(controller)
},
match: function() {
narrow.remove().removePin();
wide.setPin('#secondary_nav').addIndicators().addTo(controller);
},
unmatch: function() {
wide.remove().removePin();
var narrowpin = narrow.setPin('#secondary_nav ul').addIndicators().addTo(controller);
},
})
我只想删除开始使用JSON的<nav id="secondary_nav" class=''>
<ul>
<li class="btn"><a id='toabout' href="#about">About</a>
</li>
<li class="btn"><a id='toprojects' href="#projects">Projects</a>
</li>
<li class="btn"><a id='tocontact' class='tocontact' href="#contact_a">Contact</a>
</li>
</ul>
</nav>
之前的所有内容。这就是我的尝试:
> MongoDB shell version: 3.0.6 connecting to: reddit
> 2016-03-09T13:25:25.825+0000 E QUERY Error: don't know how to
> massage : number
> at Error (<anonymous>)
> at DBCollection._massageObject (src/mongo/shell/collection.js:132:11)
> at DBCollection.find (src/mongo/shell/collection.js:172:47)
> at (shell eval):1:35 at src/mongo/shell/collection.js:132 MongoDB shell version: 3.0.6 connecting to: reddit {
> "_id" : "566f8b91cef21a260a66030e",
> "time_recorded" : 1450150801,
这不会引发错误,但也没有效果。如何删除上面的所有文本(在不同文件中会有不同的随机消息)并保留{
?
答案 0 :(得分:0)
试试这个:
sed ':a /{/!{N;ba};s/.*{/{/' file
循环连接所有行,直到找到{
。之后,您可以应用s
命令:s/.*{/{/