If you want to construct examples yourself (that's what I'm getting from your question, but correct me if I'm wrong), use an EXAMPLE
block instead of a SRC
block:
#+BEGIN_EXAMPLE
$ ls
dir1
dir2
file1
file2
...
#+END_EXAMPLE
When exporting to HTML, this block becomes:
<pre class="example">
$ ls
dir1
dir2
file1
file2
...
</pre>
As you can see, the contents of the exported block are exactly the same as the contents of the original EXAMPLE
block.
If you actually want to run one or more commands to produce output dynamically and include both the commands and the results in your HTML document, you need to modify the SRC
block to look like this:
#+BEGIN_SRC sh :exports both
ls
#+END_SRC
If the output of the ls
command includes the directories and files you listed in your example (dir1
, dir2
, file1
, file2
), this will export to:
<div class="org-src-container">
<pre class="src src-sh">
ls
</pre>
</div>
<table>
<colgroup>
<col class="left" />
</colgroup>
<tbody>
<tr>
<td class="left">dir1</td>
</tr>
<tr>
<td class="left">dir2</td>
</tr>
<tr>
<td class="left">file1</td>
</tr>
<tr>
<td class="left">file2</td>
</tr>
</tbody>
</table>
As you can see, the code itself is wrapped in a code block, and the results are listed in a table.
Note that you will need to enable support for sh
code blocks explicitly via:
(require 'ob-sh)
(org-babel-do-load-languages 'org-babel-load-languages '((sh . t)))
This is because by default Org Babel only enables support for Emacs Lisp code blocks (as explained here).