I've recently switched from bash to zsh, and now it seems I'm experiencing my first compatibility issue. I'm trying to write a shell script that checks exif date and time info in image and video files, and have a problem with this variable:
LINES="$(exiftool -CreationDate -CreateDate -DateTimeOriginal -ModifyDate -MediaCreateDate -MediaModifyDate -TrackCreateDate -TrackModifyDate "$filename" | awk -F ': ' '{print $2}' | sort -u | wc -l)"
When the piped commands above are entered directly in terminal for a given file, the output is 2 both in bash and zsh. However, when used in a variable as above, and then the command echo $LINES
is entered, the output is 2 in bash, and 16 in zsh.
I wonder what difference zsh has here that I'm missing...
LINES
is a special parameter in zsh (and a shell variable used internally in bash) - in general, it's best to avoid ALLCAPS names for your own shell variables. – steeldriver Feb 28 at 14:16