Small questions about shell Programming

Source: Internet
Author: User
Ask a small shell programming question-Linux general technology-Linux programming and kernel information. The following is a detailed description. 6
#! /Bin/bash
# Demo for if/then/elif/else/fi
If [$ #-eq 2] // $ # What does it mean that the value is smaller than 2 and cp is as follows?
Then
Cp $1 $2 // $0 $1 $2
Elif [$ #-eq 1]
Then
Cat $1
Else
Echo $0 file [dir/ls]
Fi

7
// Sum. sh
#! /Bin/bash
Please input an integer a for read-p
I = 0
Sum = 0
While ($ I <= $ a) # How to write with ??
Do
Sum = $ [sum + $ I]
(I ++ ))
Done
The sum of the values within echo $ {a} is $ {sum}

8
How to use shell programming to print out all prime numbers within 100

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.