Reputation: 2943
I want to take a local file and zip it at some other temp location. Following is my code which is giving error
path="/home/tft/Downloads/ie.js"
temp="/home/tft/Downloads/Temp"
name=$(basename "$path")
echo "$path"
echo "$name"
echo "$temp"
echo "$temp/$name.zip" #Its output is also weird!
zip -r -j "$temp/$name.zip" $path
Getting below output:
/bin/bash test.sh
/home/tft/Downloads/ie.js
ie.js
/home/tft/Downloads/Temp
.zipjstft/Downloads/Temp
zip warning: name not matched: /home/tft/Downloads/ie.js
)zip . -i /home/tft/Downloads/ie.js -r -j /home/tft/Downloads/Temp
Upvotes: 1
Views: 73
Reputation: 75458
Your script is in DOS format. Convert it first to UNIX format:
sed -i 's|\r||' yourscript.sh
Or use dos2unix
:
dos2unix yourscript.sh
The error messages you see is caused by having an extra character (carriage return \r
) at the end of your values. This happens when your file's format is not UNIX but DOS since DOS' line endings is \r\n
where UNIX only has \n
.
Upvotes: 2