Shell脚本初学习

第一个shell程序运行,教程来自:http://jingyan.baidu.com/article/8cdccae947f83e315413cd05.html

代码如下:

1 #!/bin/sh
2 touch a.txt
3 sleep 10
4 echo "testtesttesttest">>a.txt

 

不知道为什么提示:MSYS2 terminal已停止工作。尚未解决。

 然后用git pull的代码

 1 #!/bin/bash 
 2 #mkdir  翟宇豪
 3 #cd     翟宇豪
 4 #git init
 5 #git pull https://git.coding.net/Rio56/wf.git master
 6 
 7 declare -A map=(["冉华"]="https://git.coding.net/Dawnfox/wf.git"
 8         ["刘淑霞"]="https://git.coding.net/liusx0303/CountWords.git"
 9         ["胡佑蓉"]="https://coding.net/u/huyr000/p/countWord/git"
10         ["王超"]="https://git.coding.net/SuperCodingChao/wfProject.git"
11         ["高远博"]="https://coding.net/u/Rainbows/p/wc/git"
12         ["陈建宇"]=" https://coding.net/u/MR__Chen/p/Demo/git" 
13         ["代秋彤"]="https://git.coding.net/a284617374/soft.git" 
14         ["方铭"]="https://coding.net/u/MingZi-/p/cipingtongji/git"
15         ["葛美义"]=" https://git.coding.net/gmyznb/wordcount1.git"
16         ["黄泽宇"]="https://coding.net/u/huangzy_95/p/wf/git"
17         ["贾男男"]="https://git.coding.net/lynlynyess/Wordcount.git"
18         ["贾雅杰"]="https://git.coding.net/jyj5951/wf.git"
19         ["姜珊"]="https://coding.net/u/js2017102865/p/StreamReader/git"
20         ["阚博文"]="https://git.coding.net/zbwd666/zbwd.git"
21         ["李传康"]="https://git.coding.net/lick468/wf.git"
22         ["李圆圆"]="https://git.coding.net/lyy181/count.git"
23         ["蔺依铭"]="https://git.coding.net/Hitagi123/word-count.git"
24         ["刘成志"]=" https://git.coding.net/liuchengzhi0944/word_dirt.git" 
25         ["刘耀泽"]="https://coding.net/u/liuyz349/p/word_count/git"
26         ["米赫"]="https://git.coding.net/immixiaomi/wf.git"
27         ["苗威"]="https://git.coding.net/Vrocker/wf.git"
28         ["任思佳"]="https://coding.net/u/rensijia/p/count-words/git"
29         ["邵朔"]="https://coding.net/u/ss505072461/p/wf/git"
30         ["宋雨"]="https://coding.net/u/songyuu/p/python_wf/git"
31         ["田继平"]="https://git.coding.net/tianjiping/11111.git"
32         ["王航"]="https://git.coding.net/wangh013/wordNumber.git"
33         ["王磊"]="https://git.coding.net/137911934/SE20170914.git"
34         ["王伟东"]="https://git.coding.net/wangwd/SecondAssignment.git"
35         ["王玉玲"]="https://coding.net/u/tutu123/p/tutu1234/git"
36         ["吴雨丹"]="https://git.coding.net/clairewyd/wf.git"
37         ["徐劭斌"]="https://git.coding.net/xushaobin/ConsoleApplication3.git"
38         ["杨梓瑞"]="https://git.coding.net/Vector121/homework.git"
39         ["袁玥"]="https://git.coding.net/yuanyue2017102885/wordcount_1and2.git"
40         ["翟宇豪"]="https://git.coding.net/Rio56/wf.git"
41         ["张恩聚"]="https://git.coding.net/ZhangEJ/wf.git"
42         ["邹双黛"]="https://git.coding.net/szjzsd/123.git"
43         )
44         
45 for key in ${!map[@]} ; do
46     mkdir $key
47     cd  $key
48     git init
49     git pull ${map[$key]} master
50     cd  .. 
51 done  
52 
53 
54 #echo ${!map[@]}
55 #
56 #echo ${map[@]}
57 #
58 # for key in ${!map[@]} ; do
59 #     #    echo ${map[$key]}
60 #     echo $key;
61 # done  
View Code

 生成的文件夹乱码:

对shell脚本有了一点点认识,但看它也有变量定义等等,暂时还未学习。

留一个教程之后学习 http://www.runoob.com/linux/linux-shell.html

希望有遇到过此类问题的前辈帮忙解答~

原文地址:https://www.cnblogs.com/wangc034/p/7631951.html