Executing multi-line statements in the one-line command-line

I’m using Python with -c to execute a one-liner loop, i.e.: python -c “for r in range(10): print ‘rob'” This works fine. However, if I import a module before the for loop, I get a syntax error: python -c “import sys; for r in range(10): print ‘rob'” File “<string>”, line 1 import sys; for r … Read more

How does “cat

I needed to write a script to enter multi-line input to a program (psql). After a bit of googling, I found the following syntax works: cat << EOF | psql —params BEGIN; `pg_dump —-something` update table …. statement …; END; EOF This correctly constructs the multi-line string (from BEGIN; to END;, inclusive) and pipes it … Read more