[英]Using sed to find/replace text in a certain file
I have a html file that I'm trying to use sed
to automatically find a particular line and have this replaced but I am having no joy so far.. 我有一个html文件,我正在尝试使用
sed
自动查找特定行并将其替换掉,但到目前为止我还没有高兴。
<div infinite-scroll='tabs[tabIndex].FeedService.loadFeed(false, tabs[tabIndex].FeedService.filters)'>
I would like to simply grab the entire line and replace to the following line using sed
我想简单地抓住整行并使用
sed
替换为以下行
<div infinite-scroll-labs="tabs[tabIndex].FeedService.loadFeed(false, tabs[tabIndex].FeedService.filters)" infinite-scroll-labs-container="window">
// my attempt.. //我的尝试。
sed -r --posix "infinite-scroll='tabs[tabIndex].FeedService.loadFeed(false, tabs[tabIndex].FeedService.filters, search.text, search.dateFrom, search.dateTo)' infinite-scroll-disabled='tabs[tabIndex].FeedService.busy || tabs[tabIndex].FeedService.noMoreResults || !tabs[tabIndex].active || tabs[tabIndex].FeedService.initialLoad' infinite-scroll-distance='1' infinite-scroll-immediate-check='false'\\infinite-scroll-labs="tabs[tabIndex].FeedService.loadFeed(false, tabs[tabIndex].FeedService.filters, search.text, search.dateFrom, search.dateTo)" infinite-scroll-labs-container="window" app/feed.html > $cur_dir/www/feed.html
How is the best way to go about this? 如何做到这一点的最佳方法是什么?
如果您确定这是您要更改的确切行,那么也许可以使用:
sed "s#^\(<div infinite-scroll\)='\(tabs\[tabIndex\]\.FeedService\.loadFeed(false, tabs\[tabIndex\]\.FeedService\.filters)\)'>\$#\1-labs=\"\2infinite-scroll-labs-container=\"window\">#"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.