zip command not working

后端 未结 7 913

I am trying to zip a file using shell script command. I am using following command:

  zip ./test/step1.zip $FILES

where $FILES contain all the

7条回答
  •  你的背包
    2021-02-13 06:38

    zip warning: name not matched: myfile.dat

    This means the file myfile.dat does not exist.

    You will get the same error if the file is a symlink pointing to a non-existent file.

    As you say, whatever is the last file at the of $FILES, it will not be added to the zip along with the warning. So I think something's wrong with the way you create $FILES. Chances are there is a newline, carriage return, space, tab, or other invisible character at the end of the last filename, resulting in something that doesn't exist. Try this for example:

    for f in $FILES; do echo :$f:; done
    

    I bet the last line will be incorrect, for example:

    :myfile.dat :
    

    ...or something like that instead of :myfile.dat: with no characters before the last :

    UPDATE

    If you say the script started working after running dos2unix on it, that confirms what everybody suspected already, that somehow there was a carriage-return at the end of your $FILES list.

    od -c shows the \r carriage-return. Try echo $FILES | od -c

提交回复
热议问题