#!/usr/bin/env bash
echo 'Using conditional expression:'
[[ ' ' < '0' ]] && echo ok || echo not ok
[[ ' a' < '0a' ]] && echo ok || echo not ok
echo 'Using test:'
[ ' ' \< '0' ] && echo ok || echo not ok
[ ' a' \< '0a' ] && echo ok || echo not ok
输出是:
Using conditional expression:
ok
not ok
Using test:
ok
ok
bash --version
:GNU bash, version 4.2.45(1)-release (x86_64-pc-linux-gnu)
uname -a
:Linux linuxmint 3.8.0-19-generic