regular expression

In the Unix/Mac file system, it refers to the user's home directory.

I can find no reference to it in the "expr" function.

What's the context that you saw this in?
 
It normally doesn't have special meaning. That said, it is used in awk, for field matching. This is an excerpt from O'Reilly's book "sed & awk", chapter 7.1.5:
- - - quote begins - - -
The tilde (~) operator allows you to test a regular expression against a field.

$5 ~ /MA/ { print $1 ", " $6 }


You can reverse the meaning of the rule by using bang-tilde (!~).

$5 !~ /MA/ { print $1 ", " $6 }

This rule would match all those records whose fifth field did not have "MA" in it.
- - - - quote ends - -
I hope this helps you.
 
'~' does not exist as an expression (in the sense that it would evaluate to something) in almost any software I know. Also in awk, respectively perl ('=~'), it is only an (relational) operator, e.g. in awk it says "the following must match" or "must not match" (see above, good example, btw)

The only exotic exception I know is ex, in which '~' orders to "reuse the previously replaced pattern". In any way, this is used so rarely, I have never really seen it in action.

Finally, you can stick to the opinion for good that '~' is either an operator or is simply not a metacharacter, likewise, it is read/interpreted directly in any regular expression.

In the Unix/Mac file system, it refers to the user's home directory.

Finally, yes, '~' can mean your home directory, but be careful: This has nothing to do with a) the Unix/Mac file system and b) regular expressions. This one goes to your shell's "filename substitution" which is again similar to regexps, but you should better not confuse it.
 
Back
Top