@line_cell_magic<EOL><INDENT>def sx(self, line='<STR_LIT>', cell=None):<DEDENT>
if cell is None:<EOL><INDENT>return self.shell.getoutput(line)<EOL><DEDENT>else:<EOL><INDENT>opts,args = self.parse_options(line, '<STR_LIT>', '<STR_LIT>')<EOL>output = self.shell.getoutput(cell)<EOL>out_name = opts.get('<STR_LIT>', opts.get('<STR_LIT:o>'))<EOL>if out_name:<EOL><INDENT>self.shell.user_ns[out_name] = output<EOL><DEDENT>else:<EOL><INDENT>return output<EOL><DEDENT><DEDENT>
Shell execute - run shell command and capture output (!! is short-hand).

        %sx command

        IPython will run the given command using commands.getoutput(), and
        return the result formatted as a list (split on '\\n').  Since the
        output is _returned_, it will be stored in ipython's regular output
        cache Out[N] and in the '_N' automatic variables.

        Notes:

        1) If an input line begins with '!!', then %sx is automatically
        invoked.  That is, while::

          !ls

        causes ipython to simply issue system('ls'), typing::

          !!ls

        is a shorthand equivalent to::

          %sx ls

        2) %sx differs from %sc in that %sx automatically splits into a list,
        like '%sc -l'.  The reason for this is to make it as easy as possible
        to process line-oriented shell output via further python commands.
        %sc is meant to provide much finer control, but requires more
        typing.

        3) Just like %sc -l, this is a list with special attributes:
        ::

          .l (or .list) : value as list.
          .n (or .nlstr): value as newline-separated string.
          .s (or .spstr): value as whitespace-separated string.

        This is very useful when trying to use such lists as arguments to
        system commands.