Sponsored Content
Top Forums Shell Programming and Scripting how to extract a range of lines from a file Post 53238 by beilstwh on Thursday 8th of July 2004 01:49:46 PM
Old 07-08-2004
Never mind. with different search parameters, I found the answer.
use a combination of head and tail will return any range you want. Sorry to bug the forum, I should have looked harder first.

For example to get lines 1001-2000 your would issue the following command.

set -A CustNo `cat RAGEFF.lst|head -2000|tail -1000|cut -f1-19 -d',' -s |sed 's/,/ /g'|sed 's/\L//g'|nawk '{ if (NF == 19) {print $1}}' `

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

retrieve lines from file which fall under the given date range

Hi, I need to retrieve the lines which fall under the given date range. eg:In a log file,i have the lines which will have the timestamp. the input will be some date range.eg: from date:03/Jan/2008,to date:24/Jul/2008.so now i want to retrieve the lines which have the timestamp between these... (5 Replies)
Discussion started by: Sharmila_P
5 Replies

2. Shell Programming and Scripting

extract number range from a file

Hi Everyone, a.txt 1272904667;1272904737;1 1272904747;1272904819;1 1272904810;1272904857;1 1272904889;1272904926;1 1272905399;1272905406;1 1272905411;1272905422;1 if i want to get the record, when the a.txt 1st field is between 1272904749 and 1272905399, any simple way by using awk,... (1 Reply)
Discussion started by: jimmy_y
1 Replies

3. Shell Programming and Scripting

Retrieve lines from a file in a given date range

Hey, guys! I am trying to retrieve lines from a file in a given date range. I tried using sed -n "/${SDATE}/,/${EDATE}/p" ~/webhits/$FILE | wc -l but that doesn't work if the starting or the end date do not match exactly. If both dates match, there are no problems (for example 25 March 2008 -... (5 Replies)
Discussion started by: oopcho
5 Replies

4. Shell Programming and Scripting

Extracting specific lines of data from a file and related lines of data based on a grep value range?

Hi, I have one file, say file 1, that has data like below where 19900107 is the date, 19900107 12 144 129 0.7380047 19900108 12 168 129 0.3149017 19900109 12 192 129 3.2766666E-02 ... (3 Replies)
Discussion started by: Wynner
3 Replies

5. Shell Programming and Scripting

copy range of lines in a file based on keywords from another file

Hi Guys, I have the following problem. I have original file (org.txt) that looks like this module v_1(.....) //arbitrary number of text lines endmodule module v_2(....) //arbitrary number of text lines endmodule module v_3(...) //arbitrary number of text lines endmodule module... (6 Replies)
Discussion started by: kaaliakahn
6 Replies

6. Shell Programming and Scripting

Remove a range of lines from a file using sed

Hi I am having some issue editing a file in sed. What I want to do is, in a loop pass a variable to a sed command. Sed should then search a file for a line that matches that variable, then remove all lines below until it reaches a line starting with a constant. I have managed to write a... (14 Replies)
Discussion started by: Andy82
14 Replies

7. Shell Programming and Scripting

Display lines of two date range from syslog file

Hi Guys, I want to display lines from Solaris syslog file but with 2 dates range. I have some similar solution (https://www.unix.com/shell-programming-scripting/39293-grep-log-file-between-2-dates-4.html) which works fine but as you know syslog has different date format (Jan 22) so this is not... (1 Reply)
Discussion started by: prashant2507198
1 Replies

8. Shell Programming and Scripting

Extract data from log file in specified range of time

I was searching for parsing a log file and found what I need in this link http://stackoverflow.com/questions/7575267/extract-data-from-log-file-in-specified-range-of-time But the most useful answer (posted by @Kent): # this variable you could customize, important is convert to seconds. # e.g... (2 Replies)
Discussion started by: kingk110
2 Replies

9. Shell Programming and Scripting

Extract range from config file matching pattern

I have config file like this: server_name xx opt1 opt2 opt3 suboptions1 #suboptions - disabled suboptions2 pattern suboptions3 server_name yy opt1 opt2 opt3 suboptions1 pattern #suboptions - disabled suboptions2 So basically I want to extract the server... (1 Reply)
Discussion started by: nemesis911
1 Replies

10. Shell Programming and Scripting

awk to print out lines that do not fall between range in file

In the awk below I am trying to print out those lines in file2 that are no between $2 and $3 in file1. Both files are tab-delimeted and I think it's close but currently it is printeing out the matches. The --- are not part of the files they are just to show what lines match or fall into the range... (6 Replies)
Discussion started by: cmccabe
6 Replies
head(1) 							   User Commands							   head(1)

NAME
head - display first few lines of files SYNOPSIS
head [-number | -n number] [filename...] DESCRIPTION
The head utility copies the first number of lines of each filename to the standard output. If no filename is given, head copies lines from the standard input. The default value of number is 10 lines. When more than one file is specified, the start of each file will look like: ==> filename <== Thus, a common way to display a set of short files, identifying each one, is: example% head -9999 filename1 filename2 ... OPTIONS
The following options are supported: -n number The first number lines of each input file will be copied to standard output. The number option-argument must be a positive decimal integer. -number The number argument is a positive decimal integer with the same effect as the -n number option. If no options are specified, head will act as if -n 10had been specified. OPERANDS
The following operand is supported: file A path name of an input file. If no file operands are specified, the standard input will be used. USAGE
See largefile(5) for the description of the behavior of head when encountering files greater than or equal to 2 Gbyte ( 2**31 bytes). EXAMPLES
Example 1: Writing the first ten lines of all files To write the first ten lines of all files (except those with a leading period) in the directory: example% head * ENVIRONMENT VARIABLES
See environ(5) for descriptions of the following environment variables that affect the execution of head: LANG, LC_ALL, LC_CTYPE, LC_MES- SAGES, and NLSPATH. EXIT STATUS
The following exit values are returned: 0 Successful completion. >0 An error occurred. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ |CSI |enabled | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ SEE ALSO
cat(1), more(1), pg(1), tail(1), attributes(5), environ(5), largefile(5), standards(5) SunOS 5.10 1 Feb 1995 head(1)
All times are GMT -4. The time now is 05:27 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy