zzx@zzx120:~/test1$ cat file.txt   
11
22
zzx@zzx120:~/test1$ cat ./read.sh
#!/bin/bash
while read line
do
#echo "hello"
echo $line
done < file.txt
zzx@zzx120:~/test1$ ./read.sh
11
22

百度上使用site inurl语法查询,输入site:www.baidu.com inurl:news,则会搜出所有在www.baidu.com

站点上的包含"news"子串的url.

现在有两份数据:一份是site_inurl.txt,一份是url.txt.其中,site_inurl.txt中每一行是一个site

inurl 语法组成的查询串,url.txt保存的是url列表.

在url列表中找出所有能被site_inurl.txt中查询串检索到的url

如:site中inurl.txt内容如下:

site:www.baidu.com inurl:/more

site:zhidao.baidu.com inurl:/browse/

site:www.sina.com.cn inurl:www20041223am

url.txt内容如下:

http://www.baidu.com/more/

http://www.baidu.com/guding/more.html

http://www.baidu.com/events/20060105/photomore.html

http://hi.baidu.com/browse/

http://hi.baidu.com/baidu/

http://www.sina.com.cn/head/www20021123am.html

http://www.sina.com.cn/head/www20041223am.html

则你的程序运行结果应该为:

http://www.baidu.com/more/

http://www.baidu.com/guding/more.html

http://www.sina.com.cn/head/www20041223am.html

shell程序:

#!/bin/bash

#file.sh

while read -r line

do

set $(echo $line|awk -F"[: ]" '{print $2,$4}')

grep "$1.$2" url.txt   #用inurl.txt中的关键字在url.txt中查找

done < inurl.txt

注意公式:

echo "forum-45-85.html|cut -d- -f3|cut -d. -f1

while read line do done < file的更多相关文章

  1. RHEL5.X 重启网卡出现./network-functions: line 78: .: ifcfg-eth0: file not found

    错误信息: 红帽RHEL5.5系统,重启网卡报错 [root@localhost network-scripts]# service network restart Shutting down int ...

  2. MySQL_ERROR 1231 (42000) at line XX in file 'file_name' Variable 'time_zone' can't be

    类似的错误信息如下 ERROR 1231 (42000) at line 10370 in file: '/root/sql/ultrax_170322.dmp': Variable 'time_zo ...

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

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

  4. git报错:fatal: bad config line 1 in file C:/Users/JIANGXIAOLIANG/.gitconfig

    在给git设置用户名和邮箱的时候报下面的错误:fatal: bad config line 1 in file C:/Users/JIANGXIAOLIANG/.gitconfig看提示的意思是git ...

  5. 常规问题解决:File "/usr/bin/yum", line 30 及 File "/usr/libexec/urlgrabber-ext-down", line 28

    在执行yum命令时忽然发现出现以下报错: # yum list File "/usr/bin/yum", line 30 except KeyboardInterrupt, e: ...

  6. Go to the first line OR the last line of the file

    (1) 跳到首行 :1 或 gg (2)跳到最后一行 :$ 或 G 或shift+g(大写.当前若大小写锁定直接按g,未锁定则按shift+g)

  7. idea git pull fatal: bad config line 1 in file /.gitconfig 问题处理

    在网上搜好多都是直接改username和useremail的,但是没有说明原理. 因为我的电脑是新入职接手上一家的电脑 后来在git bash 里面用$ git config user.name 原来 ...

  8. Traceback (most recent call last): File "setup.py", line 22, in <module> execfile(join(CURDIR, 'src', 'SSHLibrary', 'version.py')) NameError: name 'execfile' is not defined

    在python3环境下安装robotframework-SSHLibraray报错: Traceback (most recent call last): File "setup.py&qu ...

  9. cat file | while read line的问题

    循环中的重定向 或许你应该在其他脚本中见过下面的这种写法: while read line do        … done < file 刚开始看到这种结构时,很难理解< file是如何 ...

随机推荐

  1. Linux学习-预习第五六七章节关于用户权限管理以及磁盘文件系统

  2. 51nod 1179:最大的最大公约数

    1179 最大的最大公约数 题目来源: SGU 基准时间限制:1 秒 空间限制:131072 KB 分值: 40 难度:4级算法题  收藏  关注 给出N个正整数,找出N个数两两之间最大公约数的最大值 ...

  3. VS2012 ffmpeg 没有定义的lrint

    在common.h #ifndef AVUTIL_COMMON_H#define AVUTIL_COMMON_H下添加 #define lrint(f) (f>=0?(int32_t)(f+(d ...

  4. 指令——rm

    一个完整的指令的标准格式: Linux通用的格式——#指令主体(空格) [选项](空格) [操作对象] 一个指令可以包含多个选项,操作对象也可以是多个. 指令:rm (remove,移除.删除) 作用 ...

  5. Web安全测试学习笔记 - vulhub环境搭建

    Vulhub和DVWA一样,也是开源漏洞靶场,地址:https://github.com/vulhub/vulhub 环境搭建过程如下: 1. 下载和安装Ubuntu 16.04镜像,镜像地址:htt ...

  6. tkinter中控件menu的两种组织方法

    tkinter中,菜单控件组织方法有两种,使用中常出现混淆,为明晰各个正确用法,特整理撰写此博文.菜单控件的组织实际上是通过一个“母菜单”和“子菜单”构成,“母菜单”一方面与master连接(即与依附 ...

  7. Elasticsearch 搜索数据

    章节 Elasticsearch 基本概念 Elasticsearch 安装 Elasticsearch 使用集群 Elasticsearch 健康检查 Elasticsearch 列出索引 Elas ...

  8. 08 SSM整合案例(企业权限管理系统):08.权限控制

    04.AdminLTE的基本介绍 05.SSM整合案例的基本介绍 06.产品操作 07.订单操作 08.权限控制 09.用户操作 10.权限关联与控制 11.AOP日志 08.权限控制 SSM权限操作 ...

  9. IT日常技能:VMware网络配置

    1.0 基本概念 集线器:把一流量为M的端口分为N个端口,每个端口流量为M/N 交换机:把一流量为M的端口分为N个端口,每个端口流量仍为M 路由器:相当于两块网卡,一块连接外网并负责NAT, 另一块负 ...

  10. Tyvj1952 Easy

    %%http://hzwer.com/2838.html 比较巧妙的是原来L^2->(l+1)^1=L^2+2*L+1这样就可以递推了 “?”的贡献及时“o”贡献的1/2. #include&l ...