Reputation: 1997
Is there a way to assign a value to a variable, that value which we get in terminal by writing any command?
I try with this code:
!number_of_lines=$(wc -l < cord_19.json)
!echo $number_of_lines
I get empty output. When I run
!wc -l < cord_19.json
I get correct response with number.
Do you have idea what is wrong or how can I set variable?
Upvotes: 5
Views: 2579
Reputation: 17333
Try:
number_of_lines = !wc -l < cord_19.json
!echo $number_of_lines
or:
number_of_lines = !wc -l < cord_19.json
print(number_of_lines)
See Pipe Ipython magic output to a variable? for related discussion.
Upvotes: 5