<tfoot id='DFJlj'></tfoot>
      • <bdo id='DFJlj'></bdo><ul id='DFJlj'></ul>

        <small id='DFJlj'></small><noframes id='DFJlj'>

        <i id='DFJlj'><tr id='DFJlj'><dt id='DFJlj'><q id='DFJlj'><span id='DFJlj'><b id='DFJlj'><form id='DFJlj'><ins id='DFJlj'></ins><ul id='DFJlj'></ul><sub id='DFJlj'></sub></form><legend id='DFJlj'></legend><bdo id='DFJlj'><pre id='DFJlj'><center id='DFJlj'></center></pre></bdo></b><th id='DFJlj'></th></span></q></dt></tr></i><div id='DFJlj'><tfoot id='DFJlj'></tfoot><dl id='DFJlj'><fieldset id='DFJlj'></fieldset></dl></div>

      1. <legend id='DFJlj'><style id='DFJlj'><dir id='DFJlj'><q id='DFJlj'></q></dir></style></legend>
      2. 如何附加“python --version"的输出到 bash shell 中的文件?

        时间:2023-09-27

        1. <i id='jP5ZA'><tr id='jP5ZA'><dt id='jP5ZA'><q id='jP5ZA'><span id='jP5ZA'><b id='jP5ZA'><form id='jP5ZA'><ins id='jP5ZA'></ins><ul id='jP5ZA'></ul><sub id='jP5ZA'></sub></form><legend id='jP5ZA'></legend><bdo id='jP5ZA'><pre id='jP5ZA'><center id='jP5ZA'></center></pre></bdo></b><th id='jP5ZA'></th></span></q></dt></tr></i><div id='jP5ZA'><tfoot id='jP5ZA'></tfoot><dl id='jP5ZA'><fieldset id='jP5ZA'></fieldset></dl></div>
            <bdo id='jP5ZA'></bdo><ul id='jP5ZA'></ul>
            • <small id='jP5ZA'></small><noframes id='jP5ZA'>

                <legend id='jP5ZA'><style id='jP5ZA'><dir id='jP5ZA'><q id='jP5ZA'></q></dir></style></legend>
                <tfoot id='jP5ZA'></tfoot>
                    <tbody id='jP5ZA'></tbody>
                  本文介绍了如何附加“python --version"的输出到 bash shell 中的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试编写一个简短的脚本来将我当前的 shell 会话的某些环境变量记录到文件中.不幸的是,python --version"的输出似乎忽略了(?)>>运算符并打印到shell而不是文件.

                  I'm trying to write a short script to log certain environment variables of my current shell session to file. Unfortunately the output of "python --version" seems to ignore (?) the >> operator and prints to the shell instead to the file.

                  我的最小(非)工作示例:

                  My minimal (not) working example:

                  rm path.log
                  echo "python --version" >> path.log
                  python --version >> path.log
                  

                  我希望文件 path.log 将具有以下内容:

                  I would expect that the file path.log would then have the following content:

                  python --version
                  Python 2.6.6
                  

                  但是Python 2.6.6"这一行会打印到 shell 而不是文件.我该如何解决这个问题?

                  But the line "Python 2.6.6" is printed to the shell and not to the file. How can I fix this?

                  谢谢!

                  PS:这完全适用于

                  gcc --version
                  

                  推荐答案

                  python --version 输出到STDERR.

                  你需要将STDERR合并到STDOUT中:

                  python --version >> path.log 2>&1
                  

                  <小时>

                  作为参考,您可以通过以下方式验证此类行为:


                  For reference, you can verify such behavior by saying:

                  $ python --version 1>/dev/null
                  Python 2.7.4
                  

                  上例中的STDOUT被重定向到/dev/null.这意味着输出被发送到 STDERR.

                  The STDOUT in the above example was redirected to /dev/null. This would imply that the output is being sent to STDERR.

                  这篇关于如何附加“python --version"的输出到 bash shell 中的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何将列表附加到 pandas 列、系列? 下一篇:Python Dict 理解创建和更新字典

                  相关文章

                  <i id='GSGCu'><tr id='GSGCu'><dt id='GSGCu'><q id='GSGCu'><span id='GSGCu'><b id='GSGCu'><form id='GSGCu'><ins id='GSGCu'></ins><ul id='GSGCu'></ul><sub id='GSGCu'></sub></form><legend id='GSGCu'></legend><bdo id='GSGCu'><pre id='GSGCu'><center id='GSGCu'></center></pre></bdo></b><th id='GSGCu'></th></span></q></dt></tr></i><div id='GSGCu'><tfoot id='GSGCu'></tfoot><dl id='GSGCu'><fieldset id='GSGCu'></fieldset></dl></div>

                  <small id='GSGCu'></small><noframes id='GSGCu'>

                  <tfoot id='GSGCu'></tfoot>
                  1. <legend id='GSGCu'><style id='GSGCu'><dir id='GSGCu'><q id='GSGCu'></q></dir></style></legend>

                        <bdo id='GSGCu'></bdo><ul id='GSGCu'></ul>