<p>I'm looking for the best way to take a simple input:</p>

<pre><code>echo -n "Enter a string here: "
read -e STRING
</code></pre>

<p>and clean it up by removing non-alphanumeric characters, lower(case), and replacing spaces with underscores.</p>

<p>Does order matter? Is <code>tr</code> the best / only way to go about this?</p>

After a bit of looking around it seems
```
tr
```
is indeed the simplest way:
```
```
export CLEANSTRING="`echo -n "${STRING}" | tr -cd '[:alnum:] [:space:]' | tr '[:space:]' '-'  | tr '[:upper:]' '[:lower:]'`"
```
```
Occam's razor
, I suppose.