0

I'm writing a python program that will execute Unix commands and I have a file that ends with the extension 'tmx', I want to read that file and extract its structure, number of lines, and number of words. I tried the following code:

import os

os.system('cat file.tmx | wc')

But the output is 0, when I tried:

os.system('grep file.tmx')

I receive 256 which is wrong, then I tried:

os.system('grep "\n" file.tmx')

to count the number of new lines in the file but I get 512 which is still wrong. I tried searching on the internet on how to deal with 'tmx' files in general but couldn't find anything helpful. So could anybody please help me with this? how to deal with 'tmx' files in Unix commands?

ruohola
  • 21,987
  • 6
  • 62
  • 97

0 Answers0