<p>I am currently validating a client's HTML Source and I am getting a lot of validation errors for images and input files which do not have the Omittag. I would do it manually but this client literally has thousands of files, with a lot of instances where the  is not .</p>

<p>This client has validated some img tags (for whatever reason).</p>

<p>Just wondering if there is a unix command I could run to check to see if the  does not have a Omittag to add it.</p>

<p>I have done simple search and replaces with the following command:</p>

<pre><code>find . \! -path '*.svn*' -type f -exec sed -i -n '1h;1!H;${;g;s/&lt;b&gt;/&lt;strong&gt;/g;p}' {} \; 
</code></pre>

<p>But never something this large. Any help would be appreciated.</p>

Try this. It'll go through your files, make a
```
.orig
```
backup of each file (perl's
```
-i
```
operator), and replace
```
<img>
```
and
```
<input>
```
tags with
```
<img />
```
and
```
<input >
```
.
```
```
find . \! -path '*.svn*' -type f -exec perl -pi.orig -e 's{ ( <(?:img|input)\b ([^>]*?) ) \ ?/?> }{$1\ />}sgxi' {} \;
```
```
Given input:
```
```
<img>  <img/>  <img src="..">  <img src="" >
<input>  <input/>  <input id="..">  <input id="" >
```
```
It changes the file to:
```
```
<img />  <img />  <img src=".." />  <img src="" />
<input />  <input />  <input id=".." />  <input id="" />
```
```
Here's what the regexp is doing:
```
```
s{(<(?:img|input)\b ([^>]*?)) # capture "<img" or "<input" followed by non-">" chars
  \ ?/?>}                     # optional space, optional slash, followed by ">"
{$1\ />}sgxi                  # replace with: captured text, plus " />"
```
```