PyCat ===== .. toctree:: :maxdepth: 1 Indices and tables ------------------ * :ref:`genindex` * :ref:`modindex` * :ref:`search` Background ---------- Linux has a handy tool for displaying and concatenating files together on the command line. The tool is called, ``cat``, and a quick write-up about it can be found on Wikiepdia `here `_. The ``cat`` command is commonly called with just one filename as the only argument to it (much to the irritation of purists). In this instance, all ``cat`` does is echo the lines in the file, to the terminal. Exercise -------- Implement a reduced version of the ``cat`` command using Python (i.e. pycat). Start by only including support for echoing the contents of the file to the screen. The user should be able to type a command like the following to get it to work: .. code-block:: text pycat.py filename After you have the initial shell of the program, implement additional functionality of the ``cat`` command (such as actually concatenating multiple files together). Hints ----- Review the :py:mod:`sys` package for details on using :py:data:`sys.argv` as a simple way to get the command line arguments. Solution -------- When you are ready to see one possible solution to just echoing the contents of the file to the terminal, try :download:`this file ` .. _wikipedia_linux_cat : https://en.wikipedia.org/wiki/Cat_(Unix)