On 29/10/15 16:52, David Aldrich wrote:
Hi
I am working on Linux with Python 3.4.
I want to do a bash diff on two text files and show just the first 20
lines of diff’s output. So I tried:
>>> cmd = 'head -20 <(diff ' + file1 + ' ' + file2 + ')'
>>> subprocess.check_call(cmd, shell=True)
You could use a shell pipe in your command - and use str.format() too
for better readability, perhaps:
> cmd = 'diff {} {} | head -20'.format( file1, file2 )
> subprocess.check_call(cmd, shell=True)
Although this approach would not be recommended if file1 or file2 are
not sanitised
pd
--
https://mail.python.org/mailman/listinfo/python-list