# Why does %cat work on Unix, but not Windows?

**URL:** <https://discourse.jupyter.org/t/why-does-cat-work-on-unix-but-not-windows/2094>\
**Category:** General\
**Created:** [September 9, 2019, 4:26pm UTC](https://discourse.jupyter.org/t/why-does-cat-work-on-unix-but-not-windows/2094 "2019-09-09T16:26:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![reuven](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/reuven/32/12369_2.png) [@reuven](https://discourse.jupyter.org/u/reuven)\
**Post date:** [September 9, 2019, 4:26pm UTC](https://discourse.jupyter.org/t/why-does-cat-work-on-unix-but-not-windows/2094/1 "2019-09-09T16:26:14Z")

</div>

I teach a lot of Python courses using Jupyter, and as a Mac user, show them the contents of files using the `%cat` magic command. It would seem that `%cat` doesn’t exist or work on Windows. Now, I know that you could argue `cat` is a Unix command and thus doesn’t exist on Windows, but is there a reason this doesn’t work, when such Unixisms as `%ls` do work?

---

<div class="post-metadata">

**Author:** ![rolweber](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/rolweber/32/657_2.png) [@rolweber](https://discourse.jupyter.org/u/rolweber)\
**Post date:** [September 10, 2019, 8:10am UTC](https://discourse.jupyter.org/t/why-does-cat-work-on-unix-but-not-windows/2094/2 "2019-09-10T08:10:16Z")

</div>

Where do the `%cat` and `%ls` magics come from in the first place? I don’t see them listed among the IPython magics: [https://ipython.readthedocs.io/en/stable/interactive/magics.html](https://ipython.readthedocs.io/en/stable/interactive/magics.html)

There’s an SO answer that suggests defining `%cat` as an alias: [https://stackoverflow.com/a/32675775/5629418](https://stackoverflow.com/a/32675775/5629418)  
That alias would then behave as if you had typed `!cat`, and `!` is the magic for executing shell commands, which would explain the difference.

---

<div class="post-metadata">

**Author:** ![reuven](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/reuven/32/12369_2.png) [@reuven](https://discourse.jupyter.org/u/reuven)\
**Post date:** [September 10, 2019, 8:40am UTC](https://discourse.jupyter.org/t/why-does-cat-work-on-unix-but-not-windows/2094/3 "2019-09-10T08:40:20Z")

</div>

Aha! It never dawned on me that when you write `%cat`, Jupyter translates it and runs `!cat`. But that makes a heckuva lot of sense, and explains the difference.

I’m not about to ask my students to start with aliases, so I’ll see if there’s another good way to handle the show-a-file situation that’s cross platform.

---

<div class="post-metadata">

**Author:** ![cdeil](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/cdeil/32/1154_2.png) [@cdeil](https://discourse.jupyter.org/u/cdeil)\
**Post date:** [October 2, 2019, 8:30am UTC](https://discourse.jupyter.org/t/why-does-cat-work-on-unix-but-not-windows/2094/4 "2019-10-02T08:30:14Z")

</div>

I see there’s `%pycat` [https://ipython.readthedocs.io/en/stable/interactive/magics.html#magic-pycat](https://ipython.readthedocs.io/en/stable/interactive/magics.html#magic-pycat)

But we have the same use case / feature request to have a `%cat` (or new command with that function) that also works on Windows, so that we can shot the file contents or TXT, YAML, … files from tutorial notebooks in a cross-platform way.

Does a workaround / current solution exist?  
Is `print(pathlib.Path("file.txt").read_txt())` the simplest way?

Are devs looking at this forum? Would chances to get this increase if a feature request in the IPython tracker were filed?
