From 1074dc5de462cc80e58d7997e5b6729f7096a7a3 Mon Sep 17 00:00:00 2001 From: lizepeng <1224060318@qq.com> Date: Sun, 11 Sep 2022 11:44:49 +0800 Subject: [PATCH 01/11] 10215501417's commit --- lab1/10215501417.sh | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 lab1/10215501417.sh diff --git a/lab1/10215501417.sh b/lab1/10215501417.sh new file mode 100644 index 0000000..b22392a --- /dev/null +++ b/lab1/10215501417.sh @@ -0,0 +1,67 @@ +#!/bin/bash + +#生成50000行包含字母与数字的文件 +#需要从urandom中读取字母与数字,共50000次循环,大概需要5-10min左右。 +for((i = 0; i < 50000; i++)) +do +head -c 50 /dev/urandom | tr -dc A-Za-z0-9 >> RandFile; +echo -e \ >> RandFile; +done + +#按字母排序 +sort RandFile | uniq; +#按数字排序 +sort -n RandFile | uniq; +#重定向到SortedFile1 +sort RandFile | uniq >> SortedFile1; +#重定向到SortedFile2 +sort -n RandFile >> SortedFile2; + +#统计RandFile中 ab 出现的次数 +grep -o ab RandFile|wc -l; + +#git push到码园 +git init #初始化 +git add . #添加文件夹下所有文件 +git commit -m "lab1 first commit" #把添加的文件提交到远程版本库 +git remote add origin https://gitea.shuishan.net.cn/10215501417/csapp.git #建立远程连接 +git push -u origin master #上传代码#!/bin/bash + +#生成50000行包含字母与数字的文件 +#需要从urandom中读取字母与数字,共50000次循环,大概需要5-10min左右。 +for((i = 0; i < 50000; i++)) +do +head -c 50 /dev/urandom | tr -dc A-Za-z0-9 >> RandFile; +echo -e \ >> RandFile; +done + +#按字母排序 +sort RandFile | uniq; +#按数字排序 +sort -n RandFile | uniq; +#重定向到SortedFile1 +sort RandFile | uniq >> SortedFile1; +#重定向到SortedFile2 +sort -n RandFile >> SortedFile2; + +#统计RandFile中 ab 出现的次数 +grep -o ab RandFile|wc -l; + +#git push到码园 +git init #初始化 +git add . #添加文件夹下所有文件 +git commit -m "lab1 first commit" #把添加的文件提交到远程版本库 +git remote add origin https://gitea.shuishan.net.cn/10215501417/csapp.git #建立远程连接 +git push -u origin master #上传代码 + +#fork工作流: +#首先 fork目标仓库到自己的远程仓库 +#再git clone到自己的仓库 +git clone https://gitea.shuishan.net.cn/10215501417/Computer-Systems-Labs.git +#创建一个分支 +git checkout -b hw +#将代码文件上传 +git add 10215501417.sh +git commit -m "10215501417's cmommit" +#然后再发起一个pr到目标仓库 + From 7bd805043cf872f876a153c9b16d98fb76f8a500 Mon Sep 17 00:00:00 2001 From: lizepeng <1224060318@qq.com> Date: Sun, 11 Sep 2022 11:54:02 +0800 Subject: [PATCH 02/11] 10215501417's commit --- lab1/10215501417.sh | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/lab1/10215501417.sh b/lab1/10215501417.sh index b22392a..10d6392 100644 --- a/lab1/10215501417.sh +++ b/lab1/10215501417.sh @@ -25,33 +25,6 @@ git init #初始化 git add . #添加文件夹下所有文件 git commit -m "lab1 first commit" #把添加的文件提交到远程版本库 git remote add origin https://gitea.shuishan.net.cn/10215501417/csapp.git #建立远程连接 -git push -u origin master #上传代码#!/bin/bash - -#生成50000行包含字母与数字的文件 -#需要从urandom中读取字母与数字,共50000次循环,大概需要5-10min左右。 -for((i = 0; i < 50000; i++)) -do -head -c 50 /dev/urandom | tr -dc A-Za-z0-9 >> RandFile; -echo -e \ >> RandFile; -done - -#按字母排序 -sort RandFile | uniq; -#按数字排序 -sort -n RandFile | uniq; -#重定向到SortedFile1 -sort RandFile | uniq >> SortedFile1; -#重定向到SortedFile2 -sort -n RandFile >> SortedFile2; - -#统计RandFile中 ab 出现的次数 -grep -o ab RandFile|wc -l; - -#git push到码园 -git init #初始化 -git add . #添加文件夹下所有文件 -git commit -m "lab1 first commit" #把添加的文件提交到远程版本库 -git remote add origin https://gitea.shuishan.net.cn/10215501417/csapp.git #建立远程连接 git push -u origin master #上传代码 #fork工作流: From ab03cf6d05b7c475e5351eadb0ca34b58161ca99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8C=85=E4=BA=A6=E6=99=9F?= <10215501451@stu.ecnu.edu.cn> Date: Sun, 11 Sep 2022 17:12:28 +0800 Subject: [PATCH 03/11] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E8=87=B3=20''?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 10215501451.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 10215501451.md diff --git a/10215501451.md b/10215501451.md new file mode 100644 index 0000000..104f684 --- /dev/null +++ b/10215501451.md @@ -0,0 +1,21 @@ +touch text1.txt + +for i in `seq 50000`;do echo $RANDOM | md5sum | cut -c 1-9 ;done >> text1.txt + +export LC_ALL=C + +sort text1.txt | uniq + +sort -n text1.txt | uniq + +sort text1.txt | uniq > letter.txt + +sort -n text1.txt | uniq >> number.txt + + + +echo -e "computer\ndata\nscience\nengineering\nscience\nengineeringc\ncomputer\ncomputer\necnu\ndata" > text2.txt + +grep computer text2.txt + +grep -c computer text2.txt \ No newline at end of file From e8e50305049115362aa507219a3c5bd4a3ea8f01 Mon Sep 17 00:00:00 2001 From: YifeiLong Date: Sun, 11 Sep 2022 18:02:47 +0800 Subject: [PATCH 04/11] 10215501415 --- lab1/10215501415.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 lab1/10215501415.sh diff --git a/lab1/10215501415.sh b/lab1/10215501415.sh new file mode 100644 index 0000000..83893ef --- /dev/null +++ b/lab1/10215501415.sh @@ -0,0 +1,15 @@ +#两个字符串文件均由python生成 +#按数字排序 + +#覆盖写 +cat hw1.txt | sort | uniq -d > 1.txt +cat hw1.txt | sort -n | uniq -d > 1.txt + +#追加写 +cat hw1.txt | sort | uniq -d >> 2.txt +cat hw1.txt | sort -n | uniq -d >> 2.txt + + +#找出指定字符串 +grep computer hw1-2.txt +grep -c computer hw1-2.txt \ No newline at end of file From c173c2f1605579750d1c4853e7fe50f40aa39edc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E8=8C=9C=E9=9B=85?= Date: Sun, 11 Sep 2022 20:26:30 +0800 Subject: [PATCH 05/11] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20'lab1/10215501435.sh?= =?UTF-8?q?'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lab1/10215501435.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 lab1/10215501435.sh diff --git a/lab1/10215501435.sh b/lab1/10215501435.sh new file mode 100644 index 0000000..07be095 --- /dev/null +++ b/lab1/10215501435.sh @@ -0,0 +1,23 @@ +#!/bin/bash +#生成50行随机字符串 +for i in {1..50} +do + echo $RANDOM | md5sum | cut -c 1-9 >> random_50.txt +done +#将上述50行随机的字符串循环100次,得到5000行有规律的字符串 +times=1 +while((times<=100)) +do + head -n 50 random_50.txt >> random_5000.txt + times=`expr $times + 1` +done +#以覆盖写的方式,字母排序,输出unique行 +sort -u random_5000.txt > alph.txt +#以覆盖写的方式,数字排序,输出unique行 +sort -u -n random_5000.txt > number.txt +#以追加写的方式,字母排序,输出unique行 +sort -u random_5000.txt >> alph.txt +#以追加写的方式,数字排序,输出unique行 +sort -u -n random_5000.txt >> number.txt +#已经生成一个含有60个Computer的letter文件 +grep -c "Computer" letter.txt \ No newline at end of file From 2055189b70e8b72500d43c0f0232b4d41a1b0a7e Mon Sep 17 00:00:00 2001 From: Wu Mianzhi <10215501411@stu.ecnu.edu.cn> Date: Mon, 12 Sep 2022 11:06:24 +0800 Subject: [PATCH 06/11] Add Homework Lab1 --- lab1/10215501411.sh | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 lab1/10215501411.sh diff --git a/lab1/10215501411.sh b/lab1/10215501411.sh new file mode 100644 index 0000000..c78f8f0 --- /dev/null +++ b/lab1/10215501411.sh @@ -0,0 +1,57 @@ +SAMESTR="ThisIsTheSameString" #Same String for uniq +readonly SAMESTR + +## +# Get random integar between 1 and 100 +## +function getRandomName(){ + rnd=`expr $RANDOM % 64 + 1` + return $rnd +} + +## +# Get random string, first parametar is length +## +function getRandomString(){ + openssl rand -base64 $1 +} + +function generate(){ + size=500 + i=0 + while(( $i < $size )) + do + getRandomName + length=$? + #echo "START" + if [[ $length -ge 1 && $length -le 25 ]] + then + echo $SAMESTR + else + echo `getRandomString $length` + fi + let "i++" + done +} + +function sortByASCII(){ + generate | sort | uniq -u +} + +function sortByNumeric(){ + generate | sort --numeric-sort | uniq -u +} + +echo "Overwrite lines:" > resultASCII #this line should not appear in output file +sortByASCII > resultASCII +echo "Append lines:" >> resultASCII #this line should appear in output file +sortByASCII >> resultASCII + +echo "Overwrite lines:" > resultNumeric #this line should not appear in output file +sortByNumeric > resultNumeric +echo "Append lines:" >> resultNumeric #this line should appear in output file +sortByNumeric >> resultNumeric + +echo "Number of same string in file:" +generate > randomLines +grep --only-matching $SAMESTR < randomLines | wc --lines \ No newline at end of file From 4d0315b0f711bcf62fee6d6472ce7ae1692acae4 Mon Sep 17 00:00:00 2001 From: 10215501435 Date: Mon, 12 Sep 2022 11:22:28 +0800 Subject: [PATCH 07/11] add test.sh --- lab1/test.sh | 1 + 1 file changed, 1 insertion(+) create mode 100644 lab1/test.sh diff --git a/lab1/test.sh b/lab1/test.sh new file mode 100644 index 0000000..b1d57c2 --- /dev/null +++ b/lab1/test.sh @@ -0,0 +1 @@ +sort test.sh | uniq From e903330dca17731fcc5e68751dd06701fb67c677 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B4=AA=E8=B4=9D=E8=B4=9D?= <10215501418@stu.ecnu.edu.cn> Date: Mon, 12 Sep 2022 15:57:59 +0800 Subject: [PATCH 08/11] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20'10215501418.txt/.ke?= =?UTF-8?q?ep'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 10215501418.txt/.keep | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 10215501418.txt/.keep diff --git a/10215501418.txt/.keep b/10215501418.txt/.keep new file mode 100644 index 0000000..e69de29 From 8178347bab052089093562b4c95db3b969e77405 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B4=AA=E8=B4=9D=E8=B4=9D?= <10215501418@stu.ecnu.edu.cn> Date: Mon, 12 Sep 2022 16:02:45 +0800 Subject: [PATCH 09/11] =?UTF-8?q?=E5=88=A0=E9=99=A4=20'10215501418.txt'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 10215501418.txt/.keep | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 10215501418.txt/.keep diff --git a/10215501418.txt/.keep b/10215501418.txt/.keep deleted file mode 100644 index e69de29..0000000 From 370fe5aae4ab2915d5278b0d04f26691634f6bf7 Mon Sep 17 00:00:00 2001 From: 10215501418 <3012424413@qq.com> Date: Mon, 12 Sep 2022 18:18:54 +0800 Subject: [PATCH 10/11] homework1 --- lab1/10215501418.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 lab1/10215501418.sh diff --git a/lab1/10215501418.sh b/lab1/10215501418.sh new file mode 100644 index 0000000..2b7ace5 --- /dev/null +++ b/lab1/10215501418.sh @@ -0,0 +1,10 @@ +python 1.py > 1.1.txt +sort -d 1.1.txt > 1.2.txt --unique +sort --numeric-sort 1.1.txt > 1.2.txt --unique +sort -d 1.1.txt >> 1.3.txt --unique +sort --numeric-sort 1.1.txt >> 1.3.txt --unique + + +python 2.py > 2.txt +grep "computer" 2.txt +grep -c "computer" 2.txt \ No newline at end of file From f8541e6056a95661b16b6b650f617e65a9c0eca9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E8=8C=9C=E9=9B=85?= Date: Mon, 12 Sep 2022 18:39:34 +0800 Subject: [PATCH 11/11] =?UTF-8?q?=E5=88=A0=E9=99=A4=20'lab1/test.sh'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lab1/test.sh | 1 - 1 file changed, 1 deletion(-) delete mode 100644 lab1/test.sh diff --git a/lab1/test.sh b/lab1/test.sh deleted file mode 100644 index b1d57c2..0000000 --- a/lab1/test.sh +++ /dev/null @@ -1 +0,0 @@ -sort test.sh | uniq