Browse Source

Merge pull request 'hw1 from 10215501413' (#2) from 10215501413/Computer-Systems-Labs:10215501413/hw1 into master

Reviewed-on: https://gitea.shuishan.net.cn/52265903006/Computer-Systems-Labs/pulls/2
master
朱君鹏 2 years ago
parent
commit
1c907816a2
1 changed files with 21 additions and 0 deletions
  1. +21
    -0
      lab1/10215501413.sh

+ 21
- 0
lab1/10215501413.sh View File

@ -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;

Loading…
Cancel
Save