
Shell
perception952
这个作者很懒,什么都没留下…
展开
-
统计词频(Shell)
写一个 bash 脚本以统计一个文本文件words.txt中每个单词出现的频率。为了简单起见,你可以假设:words.txt只包括小写字母和' '。每个单词只由小写字母组成。单词间由一个或多个空格字符分隔。示例:假设 words.txt 内容如下:the day is sunny the thethe sunny is is你的脚本应当输出(以词频降序排列):the 4is 3sunny 2day 1cat word.txt | xargs -n 1 | ...转载 2020-05-14 15:05:47 · 210 阅读 · 0 评论 -
转制文件(Shell)
给定一个文件file.txt,转置它的内容。你可以假设每行列数相同,并且每个字段由' '分隔.示例:假设file.txt文件内容如下:name agealice 21ryan 30应当输出:name alice ryanage 21 30awk '{ for(i=1; i<=NF; i++){ if(NR==1){ res[i] = $i; ...转载 2020-05-14 15:51:35 · 209 阅读 · 1 评论