From 6f7fa292c22fc265fa6bea50526c17440bd8ea0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=98=89=E8=B1=AA?= <1174617612@qq.com> Date: Sat, 17 Sep 2022 00:00:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6=E8=87=B3?= =?UTF-8?q?=20'lab1'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lab1/10204804434.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 lab1/10204804434.sh diff --git a/lab1/10204804434.sh b/lab1/10204804434.sh new file mode 100644 index 0000000..49b2a04 --- /dev/null +++ b/lab1/10204804434.sh @@ -0,0 +1,28 @@ +#!/bin/bash +#生成 50000 行的文件,每一行可以包含字母、数字。长度不限制。 +for i in $(seq 1 50000) +do + echo $RANDOM | md5sum | cut -c 1-9 +done >> test.txt + +#按照字母顺序排序这个文件,输出所有的 unique 行。 +sort --unique test.txt + +#按照数字顺序排序这个文件,输出所有的 unique 行。 +sort --unique --numeric-sort test.txt + +#以覆盖写的方式将上述的结果重定向到一个文件中 +sort --unique test.txt > test1.txt +sort --unique --numeric-sort test.txt > test1.txt + +#以追加写的方式将上述的结果重定向到一个文件中 +sort --unique test.txt >> test1.txt +sort --unique --numeric-sort test.txt >> test1.txt + + + +#找"computer” +grep -o "computer" com.txt + +#统计其中包含多少 computer +grep -o "computer" com.txt | grep -c "computer" \ No newline at end of file