|
|
@ -0,0 +1,28 @@ |
|
|
|
作业1: |
|
|
|
#生成50000行文件 |
|
|
|
for i in $(seq 1 50000) |
|
|
|
do |
|
|
|
echo $RANDOM|md5sum|cut -c 1-9 |
|
|
|
done >> test.txt |
|
|
|
|
|
|
|
#按照字母顺序排序,输出unique行 |
|
|
|
sort -u test.txt |
|
|
|
|
|
|
|
#按照数字顺序排序,输出unique行 |
|
|
|
sort -u -n test.txt |
|
|
|
|
|
|
|
#以覆盖写的方式重定向到一个文件(1.txt) |
|
|
|
sort -u test.txt > 1.txt |
|
|
|
sort -u -n test.txt > 1.txt |
|
|
|
|
|
|
|
#以追加写的方式重定向到一个文件(2.txt) |
|
|
|
sort -u test.txt >> 2.txt |
|
|
|
sort -u -n test.txt >> 2.txt |
|
|
|
|
|
|
|
作业2: |
|
|
|
#已随机生成文件 |
|
|
|
#找"computer" |
|
|
|
grep "computer" computer.txt |
|
|
|
|
|
|
|
#统计其中包含多少"computer" |
|
|
|
grep -o "computer" computer.txt|wc -w |