Python - using subprocess to call sed? -
Python - using subprocess to call sed? -
i wish phone call sed python using subprocess. script tried using below. however, pipes sed output standard terminal. seems '>' operator not recognised within subprocess.call statement. suggestions?
import sys import os import subprocess files = os.listdir(sys.argv[1]) count = 0 f in files: count += 1 inp = sys.argv[1] + f outp = '../' + str(count) + '.txt' sub = subprocess.call(['sed', 's/\"//g', inp, '>', outp])
also - file names have spaces in them, i.e., " file1 .txt". issue? sed command works fine when phone call sed terminal, not script.
thanks.
use
out_file = open(outp, "w") sub = subprocess.call(['sed', 's/\"//g', inp], stdout=out_file )
python sed subprocess
Comments
Post a Comment