Display certain line(s) from a text file in Linux.
Purpose:
Display certain line or lines from a text file, such as :
Display the 1000th line from file message.log
or
Display the lines between 1000 and 1020 from file message.log
Solution:
Using sed:
sed -n '1000,1020p' message.log
sed -n '1000,1020p; 1021q' message.log #break after read out 1020th line.
Using awk:
awk '{if ((NR >= 1000) && (NR <= 1020)) print $0}' message.log
Using cat && grep:
cat -n message.log | grep -A 20 '^ *1000'
Using nl && grep:
nl message.log | grep -A 20 '^ *1000'
Using tail && head:
tail -n +1000 message.log | head 20
head -n 1000 message.log | tail +20
Ref:
Display certain line(s) from a text file in Linux.的更多相关文章
- create feature from text file
'''---------------------------------------------------------------------------------- Tool Name: Cre ...
- New text file line delimiter
Window -> Preferences -> General -> Workspace : Text file encoding :Default : 选择此项将设定文件为系统默 ...
- [转]How to Import a Text File into SQL Server 2012
Importing a using the OpenRowSet() Function The OPENROWSET bulk row set provider is accessed by call ...
- unity, read text file
using System.IO; //test read txt //Resources.Load(...) loads an asset stored at path in a Res ...
- [转]Loading, Editing, and Saving a Text File in HTML5 Using Javascript
本文转自:http://thiscouldbebetter.wordpress.com/2012/12/18/loading-editing-and-saving-a-text-file-in-htm ...
- eclipse设置text file encoding UTF-8和文件的换行符 Unix 格式
阿里华山版java开发手册代码格式第10条: 步骤:1.Window - Preferences, 2.左边选择 General - Workspace , 3.右边Text file encodin ...
- shell脚本执行时报"bad interpreter: Text file busy"的解决方法
在执行一个shell脚本时,遇到了“-bash: ./killSession.sh: /bin/bash: bad interpreter: Text file busy”错误提示,如下所示: [or ...
- eclipse的使用-------Text File Encoding没有GBK选项的设置
eclipse的使用-------Text File Encoding没有GBK选项的设置 2013-12-25 09:48:06 标签:java myeclipse使用 有一个项目是使用GBK编码的 ...
- Writing Text File From A Tabular Block In Oracle Forms
The example given below for writing text file or CSV using Text_IO package from a tabular block in O ...
随机推荐
- exe4j将可执行的jar封装成exe文件
1,将java项目打包成可执行的jar:https://www.cnblogs.com/3b2414/p/9355292.html, 2,下载好exe4j工具, 3,首先注册,如果你不注册,打包好的软 ...
- Android开发笔记(1)——View
笔记链接:http://www.cnblogs.com/igoslly/p/6781592.html 一.View基础知识 IDE——Integrated Developme ...
- iOS从手机相册选择一张照片并显示 Objective-C
要先给app设置访问相册的权限: 在项目的Info.plist文件里添加Privacy - Photo Library Usage Description权限 ViewController.h: #i ...
- DIV水平 垂直居中CSS
/*实现一.原理:要让div等块级元素水平和垂直居中,必需知道该div等块级元素的宽度和高度,然后设置位置为绝对位置,距离页面窗口左边框和上边框的距离设置为50%,这个50%就是指页面窗口的宽度和高度 ...
- public private protected
初学C++的朋友经常在类中看到public,protected,private以及它们在继承中表示的一些访问范围,很容易搞糊涂.今天本文就来十分分析一下C++中public.protected及pri ...
- 梦想CAD控件网页版线型
增加线型 主要用到函数说明: _DMxDrawX::AddLinetype 增加一个线型定义.详细说明如下: 参数 说明 BSTR pszName 线型名 BSTR pszLineDefine 线定义 ...
- Redis系列(八)--缓存穿透、雪崩、更新策略
1.缓存更新策略 1.LRU/LFU/FIFO算法剔除:例如maxmemory-policy 2.超时剔除,过期时间expire,对于一些用户可以容忍延时更新的数据,例如文章简介内容改了几个字 3.主 ...
- P1077摆花
传送 总共要摆m盆花,而每种花最多有a[i]盆.仔细思索,发现它是一个多重背包求方案数问题.但是我蒟蒻的不会,于是跑去问大佬. 以下状态转移方程及化简from rqy 如果第i个物品有a[i],每个的 ...
- boostrap标签
字体: <lead>:加强显示 <strong><b>:字体加粗 <i><em>:斜体字 .text-muted:提示,使用浅灰色(#999 ...
- 诊断:ORA-01919: role ‘PLUSTRACE’ does not exist
如下错误 SQL> grant plustrace to scott; grant plustrace to scott * ERROR at line 1: ORA-01919: role ' ...