while read line do done < file
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/guding/more.html
http://www.baidu.com/events/20060105/photomore.html
http://www.sina.com.cn/head/www20021123am.html
http://www.sina.com.cn/head/www20041223am.html
则你的程序运行结果应该为:
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的更多相关文章
- RHEL5.X 重启网卡出现./network-functions: line 78: .: ifcfg-eth0: file not found
错误信息: 红帽RHEL5.5系统,重启网卡报错 [root@localhost network-scripts]# service network restart Shutting down int ...
- 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 ...
- 刷题中熟悉Shell命令之Tenth Line和Transpose File [leetcode]
首先介绍题目中要用的4个Shell命令 sed awk head tail的常用方法.(打好地基,才能建成高楼!) sed:(转自:http://www.cnblogs.com/barrychiao/ ...
- 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 ...
- 常规问题解决: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: ...
- Go to the first line OR the last line of the file
(1) 跳到首行 :1 或 gg (2)跳到最后一行 :$ 或 G 或shift+g(大写.当前若大小写锁定直接按g,未锁定则按shift+g)
- idea git pull fatal: bad config line 1 in file /.gitconfig 问题处理
在网上搜好多都是直接改username和useremail的,但是没有说明原理. 因为我的电脑是新入职接手上一家的电脑 后来在git bash 里面用$ git config user.name 原来 ...
- 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 ...
- cat file | while read line的问题
循环中的重定向 或许你应该在其他脚本中见过下面的这种写法: while read line do … done < file 刚开始看到这种结构时,很难理解< file是如何 ...
随机推荐
- linux下anaconda的安装和使用
1.将python3设置为默认 直接执行这两个命令即可: sudo update-alternatives --install /usr/bin/python python /usr/bin/pyth ...
- POJ2533:Longest Ordered Subsequence
Longest Ordered Subsequence Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 37454 Acc ...
- DRF项目之实现用户密码加密保存
在DRF项目的开发中,我们通过直接使用序列化器保存的用户信息时,用户的密码是被明文保存到数据库中. 代码实现: def create(self, validated_data): '''重写creat ...
- 159-PHP strstr函数,取最后几个字符和除去最后几个字符
<?php $str='programming'; //定义一个字符串 $res=substr($str,-4); //处理字符串 echo "返回{$str}字符串的最后4个字符{$ ...
- 099-PHP二维数组的元素输出二
<?php $stu=array(array(76,87,68), array(65,89,95), array(90,80,66), array(90,95,65)); //定义一个二维数组 ...
- 吴裕雄--天生自然C++语言学习笔记:C++ 循环
有的时候,可能需要多次执行同一块代码.一般情况下,语句是顺序执行的:函数中的第一个语句先执行,接着是第二个语句,依此类推. 编程语言提供了允许更为复杂的执行路径的多种控制结构. 循环语句允许我们多次执 ...
- JS location.href传参及接受参数
当前页面传参 window.location.href= + "&name="+"zhangchenxao"; 下个页面接受参数 var url = l ...
- DRF教程10-关系字段
https://www.django-rest-framework.org/api-guide/relations/ 在编程中核心的就是数据结构. 关系字段用来表示model之间的关系,比如外键,m2 ...
- Java Web学生信息保存
Course.javapackage entity; public class Course { private int id; private String num; private String ...
- 每天一点点之vue框架开发 - vue-router路由进阶(路由别名、跳转、默认路由、二级路由、路由守卫)
路由别名 在main.js中的路由中添加name来创建别名 const routes = [ {path:'/footer',name:footerLink,component:Footer} ] ...