I made a short script that changes all files with one extension to a different extension. Both extensions are inputted by the user through command line arguments. I put in an if statement to handle errors but for some reason it considers everything an error and I am not sure why. I have pasted the script below. I am rather new to bash scripting so any help would be greatly appreciated!
if [[ "$#" == 0 ]] || [[ "$1" || "$2" != "."* ]]
then
echo "Parameters are not valid"
exit
fi
for f in *"$1"; do
name=${f%.*}
mv $f "$name$2"
done
[[ "$1" || "$2" != "."* ]]
[[ "$1" || "$2" != "."* ]]
should be [[ "$1" != .* ]] || [[ "$2" != .* ]]
[[ "$1" != .* ]] || [[ "$2" != .* ]]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.