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 input files. But I am getting a warning as follows
zip warning: name not matched: myfile.dat
and one more thing I observed that the file which is at last in the list of files in a folder has the above warning and that file is not getting zipped.
Can anyone explain me why this is happening? I am new to shell script world.

This means the file
myfile.datdoes 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:I bet the last line will be incorrect, for example:
...or something like that instead of
:myfile.dat:with no characters before the last:UPDATE
If you say the script started working after running
dos2unixon it, that confirms what everybody suspected already, that somehow there was a carriage-return at the end of your$FILESlist.od -cshows the \r carriage-return. Tryecho $FILES | od -c