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 to use for in linux

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

Share

Shulou(Shulou.com)05/31 Report--

This article mainly shows you "how to use for in linux", the content is easy to understand, clear, hope to help you solve doubts, the following let the editor lead you to study and learn "how to use for in linux" this article.

In linux, the for command is used to create a loop that uses a command set in the series through a loop of values, with the syntax "for variable name in values list do command sequence done".

The operating environment of this tutorial: linux7.3 system, Dell G3 computer.

What is the use of for in linux

The for command is provided in shell to create a loop that repeats through a series of values, executing a defined set of commands using one value in the series at a time.

The basic format of the for statement is as follows:

For variable name in values list do command sequence done

Provide a series of values for iteration (the result of the previous output, this sentence is used for input) in the parameter list. There are several different ways to specify values in a list.

Read the values in the list:

The most basic use of the for command is to iterate by defining a list of values in the for command. The following figure is ↓

After execution, the values assigned to T1 as shown in the figure are output one by one!

If you iterate through a value in the list, you can continue to use it by assigning other values to the variable, and the value of the iteration is the last value.

The output is as follows:

The above is all the contents of the article "how to use for in linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more 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

Servers

Wechat

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

12
Report