A For loop statement for the shell under Linux

Source: Internet
Author: User

First Category: Digital cycle
-----------------------------
for1-1.sh

#!/bin/bash    for ((i=1; i<=; i++));     do   Echo $ (expr31);    Done  

-----------------------------
for1-2.sh

#!/bin/bash    for with $ (seq1)  do    Echo $ (expr31);    Done  

-----------------------------
for1-3.sh

#!/bin/bash    for in {1.. Ten }  do  Echo $ (expr31);    Done  

-----------------------------
for1-4.sh

#!/bin/bash    awk'begin{for (i=1; i<=10; i++) Print i}'   

Type II: Character loops
-----------------------------
for2-1.sh

#!/bin/bash    for in 'ls';     do   Echo file name\!  ;    Done  

-----------------------------
for2-2.sh

#!/bin/bash    for in $* ;     do  echo $i is input chart\!  ;    Done  

-----------------------------
for2-3.sh

#!/bin/bash    for in  F1 F2 F3;    do  Echo $i is appoint;    Done  

-----------------------------
for2-4.sh

#!/bin/bash    list="rootfs usr data data2"   for inch $list;    do  Echo $i is appoint;    Done  

Class III: PATH Lookup
-----------------------------
for3-1.sh

#!/bin/bash    forfile in/proc/*;  Do  echo $file is file path \!;  Done  

-----------------------------
for3-2.sh

#!/bin/bash    forfile in $ (ls *.  SH)  do  echo $filefile path \! ;    Done  

Summarize:

It is now common to use a for-in structure, in which a function can be used to construct a range, such as $ () and ' these, which write some lookup syntax, such as LS test*, then the output file name after the traversal.

Reference:

HTTP://BLOG.CSDN.NET/BABYFISH13/ARTICLE/DETAILS/52981110 (the above content is transferred from this article)

A For loop statement for the shell under Linux

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.