Common shell programming and instances-continuous updating

Source: Internet
Author: User

This article by larrylgq prepared, reproduced please note the Source: http://blog.csdn.net/larrylgq/article/details/7395261

Author: Lu guiqiang

Email: larry.lv.word@gmail.com

Variable:
AAA = "LV"; do not use Spaces
Echo $ AAA-> LV
Echo $ {AAA} TXT-> lvtxt
Echo export aaa.txt-> lv.txt

Evaluate:
A = 1
B = 2

1: Let:
Let C = a + B
Echo $ C
3

2: $ []:
D = $ [A + B]
Echo $ d
3

3: $ (()):
E = $ (a + B ))
Echo $ E
3

Condition determination:

1: Numerical judgment:
-Ne-lt-lessthan-GT-le
If [$ A-GT 0]; then
> Echo hahaha
> Fi
Hahaha

2: String judgment:
A = A1
B = b1
If [[$ A = $ B]; then
! = <=>=-Z (whether it is empty)-N (whether it is not empty)
> Echo test
> Else echo OK
> Fi
OK
3: Others
If [[-N $ B]; then echo test; else echo OK; FI
-N is null
-F indicates whether to file
-D: directory?
-X executable?
-E exists?
-W is writable?
-R readable?
-L link?
If [-f lv]; Then ECHO yes; else echo no; FI
If [-d lv]; Then ECHO yes; else echo no; FI
A = zookeeper
If [-F $ A]; Then ECHO yes; else echo no; FI
Yes

Note: [] must contain spaces.

Loop:

1: For (I = 0; I <100; I ++) {echo $ I ;}
A space is required before echo.
2: For (I = 0; I <100; I ++); Do echo $ I; done

3: for I in {1 .. 100}; do echo $ I; done

4: Echo {1 .. 100}
Echo {A. z}
; No line feed is returned.

5: Create 1. Text and enter a number in 1. Text.
For I in 'cat 1.txt '; do echo $ I; done

Practice 1:Copy202.csv to the root@192.168.1.208 :~ /Change the name to 201-220 respectively, and then delete

For (I = 1; I <10; I ++); Do SCP 2.csv root@192.168.1.208 :~ /20ii.csv; done
For (I = 10; I <= 20; I ++); Do SCP 2.csv root@192.168.1.208 :~ /22.16i.csv; done
Or
For (I = 1; I <= 20; I ++); do if [[$ I-lt 10]; then SCP 2.csv root@192.168.1.208 :~ /N20ii.csv; else SCP 2.csv root@192.168.1.208 :~ /N2w. I .csv; FI; done

SSH root@192.168.1.208
For (I = 1; I <= 20; I ++); do if [[$ I-lt 10]; then RM ~ /20ii.csv; else RM ~ /22.16i.csv; FI; done

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.