如何检查字符串在 Bash shell 中是否有空格 [英] How to check if a string has spaces in Bash shell

查看:59
本文介绍了如何检查字符串在 Bash shell 中是否有空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设一个字符串可能类似于 "a b '' c '' d".如何检查字符串中是否包含单/双引号和空格?

Say a string might be like "a b '' c '' d". How can I check that there is single/double quote and space contained in the string?

推荐答案

case "$var" in  
     * * )
           echo "match"
          ;;
       *)
           echo "no match"
           ;;
esac

这篇关于如何检查字符串在 Bash shell 中是否有空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆