Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

About the & quot; [: too many arguments" error in Shell script

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

It is best to quote variables in double quotes, for example:

A = "a b c"

If [$a = "a b c"]; then

Echo "yes"

Fi

Run this script and you will get an error.

Should be changed to:

A = "a b c"

If ["$a" = "a b c"]; then

Echo "yes"

Fi

At this time, because the script without double quotes will be confused by the spaces in the variables, regardless of whether there are spaces in the variables, it is a good practice to put double quotation marks when referencing the variables.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report