Shell for usage

Source: Internet
Author: User

#!/bin/sh

For1 () {

For I in 1 2 3 4 5 6
Do
echo "$i"
Done

}


For1
#!/bin/sh
For2 () {
For i in {1..10}
Do
echo "$i"

Done


}

For2
#!/bin/sh

For3 () {

Sum=0
#int =1

For i in {1..100..2}
Do
Let "Sum+=i"
Done

echo "Sum is $sum"
}

For3
#!/bin/sh

For4 () {
Sum=0

For I in $ (SEQ 1 2 100)
Do
Let "Sum+=i"
Done

echo "Sum is $sum"
}

For4
#!/bin/sh

For5 () {

For file in $ (LS)

Do
echo "File: $file"
Done
}

For44 () {

For file1 in $ (LS)

Do
echo "File: $file 1"
Done


}


#for5
echo "*****************"
For44
#!/bin/sh

echo "The number of arguments is $#"

For i in "$*"
Do
echo "$i"
Done
#!/bin/sh
For8 () {
Sum=0
For ((int=1;int<200;int++))
Do
Let "Sum+=int"

Done

echo "The sum is $sum"

}


For8
#!/bin/sh

For9 () {
Sum=1


For ((i=9;i>0;i--))
Do
echo "$i"
Let "Sum*=i"
Done

echo "The sum is $sum"

}

For9

Shell for usage

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.