On Wed, Jan 6, 2021 at 9:17 AM lasizoillo lasizoillo@gmail.com wrote:
Sorry, but if I'm understanting the point is to make one-liners. For example, if I want to do something like:
$ env | grep "^XDG"
In one python one liner like
$ python -c 'import os;print("\n".join([f"{key}:{value}" for key, value in os.environ.items() if key.startswith("XDG ")]))'
I can, but If I have things that require indentation I must change it to something like:
$ python << EOF
I don't know about inferior shells, but with Bourne-compatible shells (tested in bash and dash, but probably pretty much anything), you can simply open a quote and proceed to create a multi-line command.
$ python3 -c 'for n in range(1, 10):
if n % 3: print("Not a multiple of three:", n)
'
Not a multiple of three: 1 Not a multiple of three: 2 Not a multiple of three: 4 Not a multiple of three: 5 Not a multiple of three: 7 Not a multiple of three: 8 $
ChrisA