summaryrefslogtreecommitdiff
path: root/doc/textutils.texi
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1999-10-02 11:42:26 +0000
committerJim Meyering <jim@meyering.net>1999-10-02 11:42:26 +0000
commit6c4caf0dbfc4421270627f48bfcee585cc59cc12 (patch)
tree385a67872f8ad86cb0a92109ac440409789b2cf2 /doc/textutils.texi
parent1003235282d4003000cf331b5237d2ebdace8a40 (diff)
downloadcoreutils-6c4caf0dbfc4421270627f48bfcee585cc59cc12.tar.xz
*** empty log message ***
Diffstat (limited to 'doc/textutils.texi')
-rw-r--r--doc/textutils.texi33
1 files changed, 33 insertions, 0 deletions
diff --git a/doc/textutils.texi b/doc/textutils.texi
index 52ef66e3c..16dd7d5a4 100644
--- a/doc/textutils.texi
+++ b/doc/textutils.texi
@@ -3632,6 +3632,39 @@ cat "$@@" \
| uniq -d
@end example
+@item
+Deleting a small set of characters is usually straightforward. For example,
+to remove all @samp{a}s, @samp{x}s, and @samp{M}s you would do this:
+
+@example
+tr -d axM
+@end example
+
+However, when @samp{-} is one of those characters, it can be tricky
+because @samp{-} has special meanings.
+Performing the same task as above example but also
+removing all @samp{-} characters, we might try @code{tr -d -axM}, but
+that would fail because @code{tr} would try to interpret @samp{-a} as
+a command-line option. Alternatively, we could try putting the hyphen
+inside the string, @code{tr -d a-xM}, but that wouldn't work either because
+it'd make @code{tr} remove all characters in the range @samp{a}@dots{}@samp{x}.
+One way to solve the problem is to put the hyphen at the end of the list
+of characters:
+
+@example
+tr -d axM-
+@end example
+
+More generally, use the character class notation @code{[=c=]}
+where you'd put @samp{-} (or any other character) in place of the @samp{c}:
+
+@example
+tr -d '[=-=]axM'
+@end example
+
+Note how single quotes are used in the above example to protect the
+square brackets from interpretation by a shell.
+
@end itemize