Date: Mon, 27 Mar 2017 16:01:44 +0000 (UTC) From: Brad Davis <brd@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r316030 - head/usr.bin/sed Message-ID: <201703271601.v2RG1iIr057345@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: brd (doc,ports committer) Date: Mon Mar 27 16:01:44 2017 New Revision: 316030 URL: https://svnweb.freebsd.org/changeset/base/316030 Log: Add some useful examples to the sed man page. Reviewed by: wblock, bcr MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D9958 Modified: head/usr.bin/sed/sed.1 Modified: head/usr.bin/sed/sed.1 ============================================================================== --- head/usr.bin/sed/sed.1 Mon Mar 27 16:01:16 2017 (r316029) +++ head/usr.bin/sed/sed.1 Mon Mar 27 16:01:44 2017 (r316030) @@ -31,7 +31,7 @@ .\" @(#)sed.1 8.2 (Berkeley) 12/30/93 .\" $FreeBSD$ .\" -.Dd May 10, 2016 +.Dd March 27, 2017 .Dt SED 1 .Os .Sh NAME @@ -586,6 +586,36 @@ as described in .Xr environ 7 . .Sh EXIT STATUS .Ex -std +.Sh EXAMPLES +Replace +.Ql bar +with +.Ql baz +when piped from another command: +.Bd -literal -offset indent +echo "An alternate word, like bar, is sometimes used in examples." | sed 's/bar/baz/' +.Ed +.Pp +Using backlashes can sometimes be hard to read and follow: +.Bd -literal -offset indent +echo "/home/example" | sed 's/\\/home\\/example/\\/usr\\/local\\/example/' +.Ed +.Pp +Using a different separator can be handy when working with paths: +.Bd -literal -offset indent +echo "/home/example" | sed 's#/home/example#/usr/local/example#' +.Ed +.Pp +Replace all occurances of +.Ql foo +with +.Ql bar +in the file +.Pa test.txt , +without creating a backup of the file: +.Bd -literal -offset indent +sed -i '' -e 's/foo/bar/' test.txt +.Ed .Sh SEE ALSO .Xr awk 1 , .Xr ed 1 ,
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201703271601.v2RG1iIr057345>