Gzip multiple files individually and keep the original files

后端 未结 4 807
自闭症患者
自闭症患者 2021-02-02 17:47

I am looking to gzip multiple files (into multiple .gz files) in a directory while keeping the originals.

I can do individual files using these commands:



        
4条回答
  •  野性不改
    2021-02-02 18:30

    Your > in the last command gets parsed by the same shell which runs find. Use a nested shell:

    find . -type f -name "*cache.html" -exec sh -c "gzip < {} > {}.gz" \;
    

提交回复
热议问题