The `nath`

package with `\delimgrowth=1`

is very close to your preferred style.

```
\documentclass{article}
\usepackage{amssymb}
\usepackage{nath}
\delimgrowth=1
\begin{document}
\begin{equation}
1 - (1-F(x))^n \\
\Pr(X_{(1)} \le x) \\
\mathbb{E}[\min\{X_1, X_2\} ] \\
( \pi - \arccos (\frac {y}{r}) )
\end{equation}
\end{document}
```

Read the nath guide for details, especially the part about incompatibility with `amsmath`

.

# Option 1: `sed`

The stream editing tool, `sed`

, would be a natural first choice, but the problem is that `sed`

can't match *non-greedy* regular expressions.

We need a non-greedy regular expression here- to clarify why, let's consider

```
sed -r 's/|(.*)|/\\abs{\1}/g' myfile.tex
```

If we apply this substitution to a file that contains something like

```
$|a|+|b|\geq|a+b|$
```

then we'll get

```
$\abs{a|+|b|\geq|a+b}$
```

which is clearly *not* what we want- regular expression matches like this are *greedy* by default.

To make it non-greedy, we typically use `.*?`

, but the problem is that `sed`

does not support this type of match. Happily (thanks Hendrik) we can use the following instead

```
sed -r 's/\|([^|]*)\|/\\abs{\1}/g' myfile.tex
```

Once you're comfortable that it does what you want, you can use

```
sed -ri.bak 's/\|([^|]*)\|/\\abs{\1}/g' myfile.tex
```

which will overwrite each file, and make a back up first, `myfile.tex.bak`

# Option 2: `perl`

We could, instead, use a little `perl`

one-liner:

```
perl -pe 's/\|(.*?)\|/\\abs{\1}/g' myfile.tex
```

When you're *sure* that you trust it is working correctly, you can use the following to overwrite myfile.tex

```
perl -pi -e 's/\|(.*?)\|/\\abs{\1}/g' myfile.tex
```

You can replace `myfile.tex`

with, for example, `*.tex`

to operate on all the `.tex`

files in the current working directory.

Details of `perl`

's switches are discussed here (for example): http://perldoc.perl.org/perlrun.html#Command-Switches

## Best Answer

TeX also offers a primitive parameter to always make delimiters grow.

gives the desired output.

`\delimitershortfall`

is meant to measure how much larger the content is allowed to get before the delimiters start growing, but by setting it to a negative value delimiters always grow.