(1)有一推主机地址:

a.baidu.com
.....
z.baidu.com

如何从这些数据中提取出.baidu.com之前的字母,如:a b...z?

#cat f1.txt | while read line; do echo ${line%%.*}; done

#awk -F'.' '{print $1}' f1.txt

(2)处理以下文件内容,将域名取出并进行计数排序,如处理
oldboy.log
http://www.etiantian.org/index.html
http://www.etiantian.org/1.html

http://post.etiantian.org/index.html
http://mp3.etiantian.org/index.html
http://www.etiantian.org/3.html
http://post.etiantian.org/2.html

#cut -d'/' -f3 f2.txt |sort| uniq -c

#awk -F'/' '{print $3}' f2.txt | sort | uniq -c

#sed 's/^htt.*\/\///g' f2.txt | sed 's/\/.*html$//g'  | sort | uniq -c

#cat f2.txt |tr '\/' '\n' | grep etiantian | sort | uniq -c

shell 题的更多相关文章

  1. Unix shell范例精解 课后题

    1.read  #屏幕输入read name  #输入名字 2.echo #在终端打印出内容echo "What is your name ?"  # What is your n ...

  2. 错题shell

    1.判断/root/class21/inittab.txt文件是否大于100行,如果大于,则显示”inittab is a big file.”否者显示”inittab is a small file ...

  3. 刷题记录:[De1ctf] shell shell shell

    目录 刷题记录:[De1ctf] shell shell shell 一.知识点 1.源码泄露 2.正则表达式不完善导致sql注入 3.soapclient反序列化->ssrf 4.扫描内网 5 ...

  4. shell习题第10题:打印每个单词的字数

    [题目要求] 用shell打印下面这句话中字母数小于6的单词. Bash also interprets a number of multi-character options. [核心要点] for ...

  5. shell习题第7题:备份数据库

    [题目要求] 设计一个shell脚本用来备份数据库,首先在本地服务器上保存一份数据,然后再远程拷贝一份,本地保存一周的数据,远程保存一个月 假设我们知道mysql root账号的密码,要备份的库为da ...

  6. 刷题中熟悉Shell命令之Tenth Line和Transpose File [leetcode]

    首先介绍题目中要用的4个Shell命令 sed awk head tail的常用方法.(打好地基,才能建成高楼!) sed:(转自:http://www.cnblogs.com/barrychiao/ ...

  7. 笔试算法题(53):四种基本排序方法的性能特征(Selection,Insertion,Bubble,Shell)

    四种基本算法概述: 基本排序:选择,插入,冒泡,希尔.上述算法适用于小规模文件和特殊文件的排序,并不适合大规模随机排序的文件.前三种算法的执行时间与N2成正比,希尔算法的执行时间与N3/2(或更快)成 ...

  8. shell编程题(四)

    编译当前目录下的所有.c文件 #!/bin/bash ] ;] 输入参数个数 echo "Please follow up file.c!" echo "eg: ./ma ...

  9. shell编程题(一)

    求2个数之和 #!/bin/bash function add { )); then echo "The arg in't correct" else +$)) echo $sum ...

随机推荐

  1. 父元素与子元素之间的margin-top问题

    父元素的盒子包含一个子元素盒子,给子元素盒子一个垂直外边距margin-top,父元素盒子也会往下走margin-top的值,而子元素和父元素的边距则没有发生变化. html代码: <div c ...

  2. QuickFIX/N入门:(三)如何配置QuickFIX/N

    Acceptor或者Initiator能够为您维护尽可能多的FIX会话,因而FIX会话标识的唯一性非常重要.在QuickFIX/N中,一个FIX会话的唯一标识是由:BeginString(FIX版本号 ...

  3. poj 2892

    Tunnel Warfare Time Limit: 1000MS   Memory Limit: 131072K Total Submissions: 7725   Accepted: 3188 D ...

  4. ubuntu为用户增加sudoer权限的两种方法

    方法一.使用usermod命令 新增user sudo adduser username 增加sudo权限 sudo usermod -aG sudo username sudo usermod -a ...

  5. 【QCon笔记】Native 和 Web 融合

    #main img{width:100%;} 简介 理清 Native 和 Web 的亮点和痛点,借鉴对方亮点解决自身的痛点,并给出淘系 App 在这些方面的实践. Mobile Web 的协作能力底 ...

  6. 阿里云日志api创建logStore

    , shardCount =  });                 string date = FormatRfc822Date(time);                 string con ...

  7. Nginx 使用IP限制访问来源

    在 server {... 下, 或者在 location xxx {... 下, 都可以添加如下的IP访问限制 allow 10.57.22.172; allow ; allow ; allow ; ...

  8. 关于MyBatis mapper的insert, update, delete返回值

    这里做了比较清晰的解释: http://mybatis.github.io/mybatis-3/java-api.html SqlSession As mentioned above, the Sql ...

  9. 设置root用户不保存终端历史记录到.bash_history

    在.bashrc的最后行追加 unset HISTFILE cat .bash_history 还能看到 unset HISTFILE 之前保留的命令unset HISTFILE 之后的命令不会保留, ...

  10. js 点击默认另存 ,不是打开 Blob 操作

    function savepic(obj) { if (memFileObj != undefined) { obj = memFileObj; } else { memFileObj = obj; ...