The Python code is listed as below:
from pathlib import Pathimport gzipimport shutilimport osnumber = len(list(Path('./').glob('**/*.cfg')))count = 0for filename in Path('./').glob('**/*.cfg'): file_name = str(filename) with open(file_name, 'rb') as f_in: with gzip.open(file_name+'.gz', 'wb') as f_out: shutil.copyfileobj(f_in, f_out) print(file_name, "is compressed.") os.remove(file_name) print(file_name, "is removed") count += 1 print("{0}/{1} is finished.".format(count, number))Alternative way, see this link:
find . -name *.sv1 -type f -print0 | xargs -0 -n 1 -P ${number_of_cores} gzip -9