Cleaning a WPA wordlist
The if statement can be reduced to just:

[[ ${#line} &gt;= 8 &amp;&amp; ${#line} &lt;= 63 &amp;&amp; $((++validLines)) &gt; 0 ]] 
    &amp;&amp; echo $line &gt;&gt; $outputfile || ((deletedlines++))


We use bash's [[ ... ]] shell keyword to collate our conditions together. Helpfully, [[ ... ]] supports the use of &gt;= and &lt;=. 

[[ &lt;something-to-test&gt; ]] &amp;&amp; &lt;one-command-if-test-is-true&gt; || &lt;one-command-if-test-is-false&gt; is quite a useful (IMHO!) construct in bash for implementing a if-then-else logic. The only thing to note is that you can only specify one command each for both branches.

As such, we can 'inline' our increment of validLines and do an always true comparison to simplify our if branching, namely to either (&amp;&amp;) output the line to the output file, or (||) increment our deletedLines. Otherwise, it gets slightly longer due to the required use of { ... } compound command:

[[ ${#line} &gt;= 8 &amp;&amp; ${#line} &lt;= 63 ]] 
    &amp;&amp; { ((validLines++)); echo $line &gt;&gt; $outputfile; } || ((deletedlines++))




Now onto the other parts...


fileToClean should be set as fileToClean="$1" in case the filename has spaces inside.
Multi-line echo can be done as such:

[ ! -f "$fileToClean" ] &amp;&amp; cat&lt;&lt;M &amp;&amp; exit -1

Oh noes,
We have a multi-line error message
Telling user that the file is not a regular file.

M

Your way of checking the elapsed time should be done outside your script, using the time command. time can generate more (and probably more accurate) statistics about the 'performance' of your script and is readily available, hence the suggestion as opposed to manually calculating the value(s) yourself. :)




Now do you really need to do this in bash? Here's an awk one-liner (split into three for readability):

awk '{sub(/^[ ]+/,"");sub(/[ ]+$/,"")};
    length()&gt;=8&amp;&amp;length()&lt;=63{v++;print &gt; "'"$outputfile"'" };
    END{print "Valid lines:",v"\nInvalid lines:",NR-v}' "$fileToClean"



Trim line.
If length matches, count the line and print to "$outputfile".
At the end, print the summary for valid/invalid lines.