From 30dff13665bfe669cbeb3994268984684aea8c69 Mon Sep 17 00:00:00 2001 From: GentleCold <1952173800@qq.com> Date: Sat, 10 Sep 2022 23:24:22 +0800 Subject: [PATCH] hw1 from 10215501413 --- lab1/10215501413.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 lab1/10215501413.sh diff --git a/lab1/10215501413.sh b/lab1/10215501413.sh new file mode 100644 index 0000000..6a19473 --- /dev/null +++ b/lab1/10215501413.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +# 读取随机数据并转为 base64 编码 +head -n 50000 /dev/urandom | base64 > random; +# 抽取 50000 行数据 +head -n 50000 random > random2; +# rename +rm random; +mv random2 random; + +# 按 asc 排序 +sort --unique random > unique_sort_by_asc; +# 按 num 排序 +sort --unique --numeric-sort random > unique_sort_by_num; + +# 追加写 +cat unique_sort_by_asc > totall; +cat unique_sort_by_num >> totall; + +# 匹配并统计字符 +grep -o "com" totall | wc -l > number_of_com; \ No newline at end of file