Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #12805
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Subject | Re: One line command line filter |
| Date | 2011-09-05 21:25 -0400 |
| References | <4725b2c3-d930-4fb0-9fe7-a286d150f9c5@d18g2000yqm.googlegroups.com> <mailman.782.1315261387.27778.python-list@python.org> <4e6558ce$0$29968$c3e8da3$5496439d@news.astraweb.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.786.1315272411.27778.python-list@python.org> (permalink) |
On 9/5/2011 7:18 PM, Steven D'Aprano wrote:
> Terry Reedy wrote:
>
>> The doc says "-c<command>
>> 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
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
One line command line filter Jon Redgrave <jredgrave@capisco.com> - 2011-09-05 13:38 -0700
Re: One line command line filter Thomas Jollans <t@jollybox.de> - 2011-09-05 22:47 +0200
Re: One line command line filter Jon Redgrave <jredgrave@capisco.com> - 2011-09-05 14:32 -0700
Re: One line command line filter Terry Reedy <tjreedy@udel.edu> - 2011-09-05 19:02 -0400
Re: One line command line filter Terry Reedy <tjreedy@udel.edu> - 2011-09-05 18:21 -0400
Re: One line command line filter Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-09-06 09:18 +1000
Re: One line command line filter Terry Reedy <tjreedy@udel.edu> - 2011-09-05 21:25 -0400
Re: One line command line filter Hans Mulder <hansmu@xs4all.nl> - 2011-09-06 13:15 +0200
Re: One line command line filter Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-09-06 09:29 +1000
Re: One line command line filter John Wiegley <jwiegley@gmail.com> - 2011-09-06 01:51 -0500
Re: One line command line filter Peter Otten <__peter__@web.de> - 2011-09-06 09:53 +0200
csiph-web