Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Split IPython Magic Shell Multiple Lines

Tags:

python

shell

I am trying to run a very long shell command in IPython using the ! operator. How do I split the command onto multiple lines?

For instance,

 !awk -v c=0 '{{if (a[$$1]) print $$0 a[$$1]; else if (b[$$2]) print $$0 b[$$2] else {{print $$0 " common_" c; a[$$1] = b[$$2] = " common_" c; c++}}}}' foo.txt | column -t

A command like this quickly becomes unreadable.

like image 415
bkmoney Avatar asked Oct 24 '25 23:10

bkmoney


1 Answers

Use \, press enter, continue typing, use another \ and enter until you are done.

E.g.

In [1]: !ls \
   ...: *.txt
aws-forum.txt  encyclic.txt

In [2]: 
like image 59
Jan Vlcinsky Avatar answered Oct 27 '25 13:10

Jan Vlcinsky