Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have the following script that extracts data from the EXIF command on my BusyBox ash-based system. I parse the date tag from the end of the file and use case as a final check to ensure the format is correct. My problem is the if statement at the end always seems to return true ie. d="$e - Jebby (exif" always runs. If I echo $en and echo $dn it shows $en is greater than $dn but the if statement still runs the d="$e - Jebby (exif"

x=<valid filename>
e=$(exif -d -m -t 0x9003 -- "$x" 2>/dev/null)
let l=${#e}-18
e=$(expr substr "$e" $l 19)
e="${e%[ ][0-2][0-9][:][0-6][0-9][:][0-6][0-9]*}" 
e=$(expr substr "$e" 1 4)$(expr substr "$e" 6 2)$(expr substr "$e" 9 2)
case "$e" in 
     let en=$e+3
     ds="${d% - Jebby (}"
     let dn=$ds
     if [ $en -lt $dn ]; then
        d="$e - Jebby (exif"
share|improve this question
Are you sure you're using ash, not bash or some other shell? AFAIK ash has no let built in. – terdon Jan 19 '14 at 15:25
It is a Synology NAS running busybox which my understanding is close to ash shell. Let is present but declare is not. – Wags Jan 19 '14 at 16:48
Ah, OK, my local version of ash gives various error messages when trying to run your code so I can't really test. You should probably quote the variables you are comparing: if [ "$en" -lt "$dn" ]; – terdon Jan 19 '14 at 16:50

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.