Create zip file and ignore directory structure

后端 未结 7 1056
栀梦
栀梦 2020-12-07 10:38

I need to create a zip file using this command:

zip /dir/to/file/newZip /data/to/zip/data.txt

This works, but the created zip file creates

7条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-07 11:22

    Using -j won't work along with the -r option.
    So the work-around for it can be this:

    cd path/to/parent/dir/;
    zip -r complete/path/to/name.zip ./* ;
    cd -;
    

    Or in-line version

    cd path/to/parent/dir/ && zip -r complete/path/to/name.zip ./* && cd -
    

    you can direct the output to /dev/null if you don't want the cd - output to appear on screen

提交回复
热议问题