Skip to content

Laurent Schneider

Oracle Certified Master

Tag: ksh: no space

Testing for (non-)empty string in shell

One way to test for (non-)empty string is to use test and -z (-n) $ x=foo $ test -z “$x” $ echo $? 1 This is mostly seen with an if and [ -z … ] syntax $ y=bar $ if [ -n “$y” ]; then echo non-empty; fi non-empty Instead of a variable, it… Continue reading Testing for (non-)empty string in shell

Published January 27, 2014
Categorized as linux, unix Tagged ksh: no space
Laurent Schneider
Proudly powered by WordPress.