diff options
author | brd <brd@FreeBSD.org> | 2017-05-23 22:11:45 +0000 |
---|---|---|
committer | brd <brd@FreeBSD.org> | 2017-05-23 22:11:45 +0000 |
commit | 8b9b483d0b85fd3bddfd926c1400956a50c91223 (patch) | |
tree | 8e1f3438730fc2cfe7a954d424c84eb4d30a04aa /usr.bin/sed/sed.1 | |
parent | ff54ce5cf6e6c9a42052ce51d668f6c400bd8293 (diff) | |
download | FreeBSD-src-8b9b483d0b85fd3bddfd926c1400956a50c91223.zip FreeBSD-src-8b9b483d0b85fd3bddfd926c1400956a50c91223.tar.gz |
MFC r316030, r317378: Add some useful examples to the sed man page.
Reviewed by: wblock, bcr
Differential Revision: https://reviews.freebsd.org/D9958
Diffstat (limited to 'usr.bin/sed/sed.1')
-rw-r--r-- | usr.bin/sed/sed.1 | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/usr.bin/sed/sed.1 b/usr.bin/sed/sed.1 index 370a856..9c4489a 100644 --- a/usr.bin/sed/sed.1 +++ b/usr.bin/sed/sed.1 @@ -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/g' test.txt +.Ed .Sh SEE ALSO .Xr awk 1 , .Xr ed 1 , |