# Quick Shell Scripting Examples

**URL:** <https://forum.codeselfstudy.com/t/quick-shell-scripting-examples/1528>\
**Category:** General Discussion\
**Tags:** command-line\
**Created:** [March 13, 2019, 7:29pm UTC](https://forum.codeselfstudy.com/t/quick-shell-scripting-examples/1528 "2019-03-13T19:29:55Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Josh](https://forum.codeselfstudy.com/user_avatar/forum.codeselfstudy.com/josh/32/4_2.png) [@Josh](https://forum.codeselfstudy.com/u/Josh)\
**Post date:** [March 17, 2019, 8:23pm UTC](https://forum.codeselfstudy.com/t/quick-shell-scripting-examples/1528/2 "2019-03-17T20:23:22Z")

</div>

If you learn how to use and combine [various commands](https://forum.codeselfstudy.com/t/command-line-study-guide/1439) it can really speed up work. Today I was looking for a way to turn multiple Org Mode files into a single, readable HTML file. The filenames are in the format `2019-03-17-Sunday.org`, and I wanted them in order of date. I was able to quickly do it like this:

```nohighlight
$ cat $(ls -1 | sort | grep org$) | pandoc -f org -t html > output.html

```

Explanation:

1. `cat` – concatenates multiple files to stdout
2. `$()` – evaluates the commands inside the parentheses
3. `ls -1` – prints a list of files in one column
4. `|` – pipes the output of one command into the next command
5. `sort` – sorts the results (by date in this case)
6. `grep org$` – this filters out any files that don’t have `org` as the last part of the filename (excludes directories and backup files that end with a tilde, like `filename.org~`)
7. `pandoc -f org -t html` – [pandoc](https://pandoc.org/) is a tool to convert between formats, in this case from (`-f`) Org Mode to (`-t`) HTML
8. `>` this sends the output to a file named `output.html`

---

_[View the full topic](https://forum.codeselfstudy.com/t/quick-shell-scripting-examples/1528)._
