Hacker News new | ask | show | jobs
by jvanderbot 819 days ago
import os import os.subprocess #is that right? subprocess.execute(f'tar cvzf t.tar.gz {' '.join(list_of_files)}')

Did I do that right?

or was it

`tar cvzf t.tar.gz *`

1 comments

    import subprocess

    subprocess.run(['tar', 'cvzf', 't.tar.gz', *list_of_files])
or indeed

    import os, subprocess

    subprocess.run(['tar', 'cvzf', 't.tar.gz', *(f.path for f in os.scandir('.'))])
if you need files from the current directory