Skip to content

Instantly share code, notes, and snippets.

@kaosf
Created February 10, 2013 17:41
Show Gist options
  • Save kaosf/4750383 to your computer and use it in GitHub Desktop.
Save kaosf/4750383 to your computer and use it in GitHub Desktop.
string comparation
#! /bin/bash
# if [ $1 = '' ]; then
# if [ -n $1 ]; then
if [ -n "$1" ]; then
echo 'arg1 length > 0'
else
echo 'arg1 length = 0'
fi
# if [ $1 = 'unk' ]; then
if [ " $1" = ' unk' ]; then
echo 'unk; ok'
else
echo "$1 is NOT unk; error" 1>&2
exit 1
fi
echo 'end'
# ref. http://shellscript.sunone.me/if_and_test.html
# http://furyo.on-air.ne.jp/linux/bash.html
# http://x68000.q-e-d.net/~68user/unix/pickup?keyword=unexpected&target=command
# qiita: http://qiita.com/items/4e6a7f9623e03b043ddd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment