---
title: "shell\u3000判断字符串为空的方法汇总"
author: "daizj"
date: "2019-04-19T09:36:07Z"
tags: []
categories: ["编程语言"]
slug: "shell"
draft: false
lastmod: "2019-04-19T09:37:25Z"
id: 2440258
url: "https://daizj.iteye.com/blog/2440258"
---

1.-z判断

-z string

if 
then
    echo "是空字符串"
fi


2.拼加字符串再比较

if 
then
    echo "是空字符串"
fi


3.直接使用变量判断

if 

then
   echo "非空"
 else
    echo "空"
fi