Skip to main content
replaced http://unix.stackexchange.com/ with https://unix.stackexchange.com/
Source Link

While chaos's answerchaos's answer is good to be used in interactive shells, this one can be used as a POSIX script, for example if you need to do this periodically and/or do it on another computers.

#!/bin/sh
i=0
while test "$((i+=1))" -lt 366 ; do
    for j in 00 06 12 18 ; do
        file="GLDAS_NOAH025SUBP_3H.A2003$(printf '%03d' "$i").${j}00.001.2015210044609.pss.grb"
        test -e "$file" || echo "$file"
    done
done

(seq or brace expansion aren't specified by POSIX.)

While chaos's answer is good to be used in interactive shells, this one can be used as a POSIX script, for example if you need to do this periodically and/or do it on another computers.

#!/bin/sh
i=0
while test "$((i+=1))" -lt 366 ; do
    for j in 00 06 12 18 ; do
        file="GLDAS_NOAH025SUBP_3H.A2003$(printf '%03d' "$i").${j}00.001.2015210044609.pss.grb"
        test -e "$file" || echo "$file"
    done
done

(seq or brace expansion aren't specified by POSIX.)

While chaos's answer is good to be used in interactive shells, this one can be used as a POSIX script, for example if you need to do this periodically and/or do it on another computers.

#!/bin/sh
i=0
while test "$((i+=1))" -lt 366 ; do
    for j in 00 06 12 18 ; do
        file="GLDAS_NOAH025SUBP_3H.A2003$(printf '%03d' "$i").${j}00.001.2015210044609.pss.grb"
        test -e "$file" || echo "$file"
    done
done

(seq or brace expansion aren't specified by POSIX.)

added 2 characters in body
Source Link
mikeserv
  • 59.4k
  • 10
  • 122
  • 242

While chaos's answer is good to be used in interactive shells, this one can be used as a POSIX script, for example if you need to do this periodically and/or do it on another computers.

#!/bin/sh
i=0
while test $"$((i+=1))" -lt 366 ; do
    for j in 00 06 12 18 ; do
        file="GLDAS_NOAH025SUBP_3H.A2003$(printf '%03d' "$i").${j}00.001.2015210044609.pss.grb"
        test -e "$file" || echo "$file"
    done
done

(seq or brace expansion aren't specified by POSIX.)

While chaos's answer is good to be used in interactive shells, this one can be used as a POSIX script, for example if you need to do this periodically and/or do it on another computers.

#!/bin/sh
i=0
while test $((i+=1)) -lt 366 ; do
    for j in 00 06 12 18 ; do
        file="GLDAS_NOAH025SUBP_3H.A2003$(printf '%03d' "$i").${j}00.001.2015210044609.pss.grb"
        test -e "$file" || echo "$file"
    done
done

(seq or brace expansion aren't specified by POSIX.)

While chaos's answer is good to be used in interactive shells, this one can be used as a POSIX script, for example if you need to do this periodically and/or do it on another computers.

#!/bin/sh
i=0
while test "$((i+=1))" -lt 366 ; do
    for j in 00 06 12 18 ; do
        file="GLDAS_NOAH025SUBP_3H.A2003$(printf '%03d' "$i").${j}00.001.2015210044609.pss.grb"
        test -e "$file" || echo "$file"
    done
done

(seq or brace expansion aren't specified by POSIX.)

don't trip up if i was set in the environment
Source Link
Gilles 'SO- stop being evil'
  • 865.4k
  • 205
  • 1.8k
  • 2.3k

While chaos's answer is good to be used in interactive shells, this one can be used as a POSIX script, for example if you need to do this periodically and/or do it on another computers.

#!/bin/sh
i=0
while test $((i+=1)) -lt 366 ; do
    for j in 00 06 12 18 ; do
        file="GLDAS_NOAH025SUBP_3H.A2003$(printf '%03d' "$i").${j}00.001.2015210044609.pss.grb"
        test -e "$file" || echo "$file"
    done
done

(seq or brace expansion aren't specified by POSIX.)

While chaos's answer is good to be used in interactive shells, this one can be used as a POSIX script, for example if you need to do this periodically and/or do it on another computers.

#!/bin/sh
while test $((i+=1)) -lt 366 ; do
    for j in 00 06 12 18 ; do
        file="GLDAS_NOAH025SUBP_3H.A2003$(printf '%03d' "$i").${j}00.001.2015210044609.pss.grb"
        test -e "$file" || echo "$file"
    done
done

(seq or brace expansion aren't specified by POSIX.)

While chaos's answer is good to be used in interactive shells, this one can be used as a POSIX script, for example if you need to do this periodically and/or do it on another computers.

#!/bin/sh
i=0
while test $((i+=1)) -lt 366 ; do
    for j in 00 06 12 18 ; do
        file="GLDAS_NOAH025SUBP_3H.A2003$(printf '%03d' "$i").${j}00.001.2015210044609.pss.grb"
        test -e "$file" || echo "$file"
    done
done

(seq or brace expansion aren't specified by POSIX.)

Source Link
MichalH
  • 2.5k
  • 1
  • 18
  • 30
Loading