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

How linux uses double quotes to refer to variables

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly introduces how linux uses double quotation marks to quote variables, which is very detailed and has certain reference value. Friends who are interested must finish reading it!

Use double quotation marks to reference variables

Using double quotation marks when referencing (using the value of a variable) helps prevent unnecessary matching due to the separation of words caused by spaces and the recognition and extension of wildcards.

Look at the following example:

#! / bin/bash # Let the script exit set-o errexit # if the command fails, let the script exit set-o nounset echo "Names without double quotes" echo names= "Tecmint FOSSMint Linusay" for name in $names; do echo "$name" done echo echo "Names with double quotes" echo for name in "$names"; do echo "$name" done exit 0

Save the file and exit, and then run as follows:

$. / names.sh

Use double quotation marks in a script

The above is all the content of the article "how linux uses double quotes to reference variables". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

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

Development

Wechat

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

12
Report