Date: Fri, 4 Mar 2016 08:27:59 +0000 From: Guy TABRAR <Guy.TABRAR@uk.bnpparibas.com> To: David Banning <david+dated+1457496338.968870@skytracker.ca>, "questions@freebsd.org" <questions@freebsd.org> Subject: RE: sed help please Message-ID: <2112385FC012E541A52D6A28563A5572A03A54@LONS00110044.mercury.intra> In-Reply-To: <20160304040536.GA7729@skytracker.ca> References: <20160304040536.GA7729@skytracker.ca>
next in thread | previous in thread | raw e-mail | index | archive | help
# echo -e "line1\nline2\nfoo\nline4\nline5\nbar\nline7" | sed -n '/foo/,/bar/p'
foo
line4
line5
bar
Regards
Guy
-----Original Message-----
From: owner-freebsd-questions@freebsd.org [mailto:owner-freebsd-questions@freebsd.org] On Behalf Of David Banning
Sent: 04 March 2016 04:06
To: questions@freebsd.org
Subject: sed help please
I am trying to change hundreds of lines of text. Given the following text;
line 1
line 2 foo take this text
line 3
line 4
line 5 bar leave this text
line 6
line 7
I need a sed command that would take everything between foo and bar - including foo and bar.
Ideally the output would look like;
line 1
line 2
leave this text
line 6
line 7
Keep in mind that foo and bar appear in different locations - sometimes at the beginning of a line, sometimes at the end, and sometimes in the middle. I found someone who posted the following solution;
sed '/foo/,/bar/{s/./x/g}' file
but I found that this does not execute under FreeBSD. I have looked around for differences between FreeBSD and other unix like SED operations but only see the -s "", regarding backup file.
Any pointers would be helpful.
_______________________________________________
freebsd-questions@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org"
___________________________________________________________
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and delete this e-mail. Any unauthorised copying, disclosure or distribution of the material in this e-mail is prohibited.
Please refer to http://www.bnpparibas.co.uk/en/email-disclaimer/ for additional disclosures.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?2112385FC012E541A52D6A28563A5572A03A54>
