Hi,

I am using the command in python from a linux system:

import os
os.system('grep "^[0-9]" data.txt | wc -l')

The output of this is an integer like 115. Can I assign this to a variable somehow? For example:

x=os.system('grep "^[0-9]" data.txt | wc -l')
DOES NOT WORK.

Please help.

Thank you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.