473,406 Members | 2,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

How to grep from line n1 to line n2 in a file?

I have to grep a file from line n1 and n2. Is there a single command unix to do that?
Mar 10 '11 #1
1 2246
jjdot
11
awk '{ if (n1 <= NR && NR <= n2) print NR $0; }' yourfile | grep expression
Mar 10 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: David Morgenthaler | last post by:
How does one overide the iterator implied by the construct "for line in file:"? For example, suppose I have a file containing row,col pairs on each line, and I wish to write a subclass of file...
4
by: Cordula's Web | last post by:
Hello, here's a strange bug (?) I've came across (using Python 2.2): # loop_1 for line in file: if some_condition(line): break do_something() # loop_2
3
by: danpres2k | last post by:
Hello, I have a file with email address at a lot of junk data. I want to get the email addresses out of that file so that each email address is stored at a new line. I am trying to do...
13
by: Dan V. | last post by:
How do I create a one line text file with these control codes? e.g.: 144 = 0x90 and 147 = 0x93? I am trying to create a one line text file with these characters all one one row with no spaces. ...
1
by: Jesse | last post by:
I'm having trouble finding a way to read a line from a file until a space or tab occurs. Currently I'm using FileStream* fs = new FileStream(path, FileMode::Open); StreamReader *sr = new...
4
by: Sinan Nalkaya | last post by:
hello all, i searched and google long long time but couldnt find any result, i want pop the first line from file, i dont want to read all file contents because file is being updated from another...
8
by: MLH | last post by:
Am trying to import 20,000+ lines of text in a file FTP'd from a UNIX platform to windows via FTP session in a DOS box. About 2000 records have multiple lines in them separated by CRLF's. ...
1
by: thesafetylemur | last post by:
Howdy, (I'm a newbie C programmer, by the way...) How would one go about reading a whole line from file? I was told that something like: fscanf("%s\n", string); but it wasn't working for me.......
11
by: elrondrules | last post by:
Hi Am pretty new to python and hence this question.. I have file with an output of a process. I need to search this file one line at a time and my pattern is that I am looking for the lines...
9
by: mijn naam | last post by:
Hi, I tried searching myself using google and on php.net, but too much irrelevant answers and not a single one helpful so please bare with me. Could someone please show me how to get one line...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.