Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'escape': 0.04; 'string.': 0.04; 'sys': 0.05; 'ignored': 0.07; 'received:verizon.net': 0.07; 'terry': 0.07; 'python': 0.08; 'bash': 0.09; 'command-line': 0.09; 'command.': 0.09; 'newline': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; '"import': 0.16; 'guessing': 0.16; 'matched': 0.16; 'newlines': 0.16; 'reedy': 0.16; 'simple:': 0.16; 'subject:command': 0.16; 'using,': 0.16; 'wrote:': 0.16; 'linux': 0.17; 'jan': 0.19; 'wrote': 0.20; 'header:In-Reply-To:1': 0.22; 'pm,': 0.24; 'command': 0.24; "python's": 0.24; 'shell': 0.24; 'says': 0.25; 'code': 0.25; 'windows': 0.26; 'depends': 0.28; 'print': 0.29; 'separated': 0.30; 'there': 0.33; 'to:addr:python- list': 0.33; 'however,': 0.34; 'header:User-Agent:1': 0.34; 'idea': 0.34; 'doc': 0.34; 'header:X-Complaints-To:1': 0.35; 'skip:" 10': 0.36; 'statements': 0.37; 'put': 0.37; 'but': 0.37; 'something': 0.37; 'could': 0.38; 'received:org': 0.38; 'steven': 0.38; 'subject:: ': 0.39; 'header:Mime-Version:1': 0.39; 'either': 0.39; 'to:addr:python.org': 0.39; 'more': 0.60; 'double': 0.61; 'imagine': 0.71; 'subject:line': 0.73; 'subject:One': 0.77 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: One line command line filter Date: Mon, 05 Sep 2011 21:25:44 -0400 References: <4725b2c3-d930-4fb0-9fe7-a286d150f9c5@d18g2000yqm.googlegroups.com> <4e6558ce$0$29968$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-74-109-121-73.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0) Gecko/20110812 Thunderbird/6.0 In-Reply-To: <4e6558ce$0$29968$c3e8da3$5496439d@news.astraweb.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 29 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1315272411 news.xs4all.nl 2424 [2001:888:2000:d::a6]:55838 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:12805 On 9/5/2011 7:18 PM, Steven D'Aprano wrote: > Terry Reedy wrote: > >> The doc says "-c >> Execute the Python code in command. command can be one or more >> statements separated by newlines," >> >> However, I have no idea how to put newlines into a command-line string. > > I imagine that it depends on the shell you are using, but bash on Linux > makes it simple: double quotes "..." are like Python's triple-quoted > strings in that they can include newlines. > > [steve@sylar python]$ ls f*.py | python -c "import sys >> print sys.stdin.read()" > factorial.py > fetchqm.py I was guessing that whoever wrote the doc could do something like that. As far as I know, there is no way to escape a newline with Windows cmd.exe. (Someone please tell me if I am wrong!) An "unmatched" quote is either ignored or matched by the newline! C:\Programs\Python32> python -c "print('haha') haha -- Terry Jan Reedy