Im trying to get the number of lines in the output of ls -l | awk '{print $1}'
, which is 7 as shown below.
total
drwxrwxr-x
drwxrwxr-x
-rw-rw-r--
-rw-rw-r--
-rw-rw-r--
-rw-r--r--
I tried to store this value in the variable count
but when I print count, the value is 0 instead of 7. I don't know why.
import subprocess
count = subprocess.call('ls -l | awk '{print $1}' | wc -l', shell=True)
print count
OUTPUT:
7
0