05-25-2010
How abt this code snippet
l=$(grep -n -N 1 "pattern" filename | cut -d":" -f1)
i -= 10
j += 10
sed -n "$j"p filename
sed -n "$i"p filename
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I have a shell script and want to assign a value to a variable. The value is the line exctrated from a file using the line number. The line number it is not fix, and could change any time.
I have tried sed, awk, head .. See my script
# Get randome line number from the file
#selectedline = `awk... (1 Reply)
Discussion started by: zambo
1 Replies
2. Shell Programming and Scripting
Hello,
I am having trouble extracting a specific line from a file when the line number is known. My first attempt involved grep -n 'hi' (the word 'hi will always be there) to get the line number before the line that I actually want (line 4).
Extra Notes:
-I am working in a bash script.
-The... (7 Replies)
Discussion started by: grandtheftander
7 Replies
3. Shell Programming and Scripting
hi dudes,
I have a text file in the below format
1 s sanity /u02
2 r script1 /u02
3 s sanity /u02
Please tell me a script to read this file line by line, I wrote the below script , but it is printing only 1st line not printing rest... (7 Replies)
Discussion started by: shirdi
7 Replies
4. Shell Programming and Scripting
FOLKS ,
i have a text file that is generated automatically of an another korn shell script, i want to bring in the fifth line of the text file in to my korn shell script and look for a particular word in the line . Can you all share some thoughts on this one.
thanks...
Venu (3 Replies)
Discussion started by: venu
3 Replies
5. Shell Programming and Scripting
I have a file that I do a count on :
cp $file data1
x=$(grep -c "Considerations:" data1)and I need to cut the file after the 10th occurrence of the word 'Considerations:' in $file (1 Reply)
Discussion started by: dba_frog
1 Replies
6. Shell Programming and Scripting
Hi guys,
does anyone know how to extract(grep) a line from the file, if I know the line number?
Thanks a lot. (9 Replies)
Discussion started by: aoussenko
9 Replies
7. Shell Programming and Scripting
I have a LOG file which looks like this
Import started at: Mon Jul 23 02:13:01 EDT 2012
Initialization completed in 2.146 seconds.
--------------------------------------------------------------------------------
--
Import summary for Import item: PolicyInformation... (8 Replies)
Discussion started by: biztank
8 Replies
8. Shell Programming and Scripting
Hi experts,
Need your help on how to insert carriage return after the 10th char position of each line in a file and then add two blank spaces after the carriage return.
Example:
>cat test.txt
testingline
dummystring
samplesample
teststringline
Expected output should be..
... (2 Replies)
Discussion started by: brichigo
2 Replies
9. Shell Programming and Scripting
In the below perl code I am using tags within each line to extract certain information. The tags that are used are:
STB >0.8 is STRAND BIAS otherwise GOOD
FDP is the second number
GO towards the end of the line is read into an array and the value returned is outputed, in the first line that... (1 Reply)
Discussion started by: cmccabe
1 Replies
10. UNIX for Beginners Questions & Answers
Input file:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 (6 Replies)
Discussion started by: Sagar Singh
6 Replies
LEARN ABOUT DEBIAN
pod::index::entry
Pod::Index::Entry(3pm) User Contributed Perl Documentation Pod::Index::Entry(3pm)
NAME
Pod::Index::Entry - Represents Pod search result
SYNOPSIS
use Pod::Index::Entry;
my $entry = Pod::Index::Entry->new(
keyword => 'constructors',
podname => 'perlobj',
line => 42,
filename => '/usr/lib/perl5/5.8.7/pod/perlobj.pod',
context => 'Using POD',
);
# trivial accessors
my $podname = $entry->podname;
my $filename = $entry->filename;
my $line = $entry->line;
my $context = $entry->context;
my $keyword = $entry->keyword;
# extract the POD for this entry
my $pod = $entry->pod;
DESCRIPTION
This class represents a POD index entry. An entry is defined by the podname/filename, line number, and context. The entry object also has
the ability to extract the POD "scope" from the filename.
METHODS
new
my $q = Pod::Index::Entry->new(%args);
Create a new search object. Possible arguments are:
podname
The name of the pod, such as .
filename
The filename for the pod, such as Data/Dumper.pm.
line
The line number where the scope of this entry begins.
context
The title of the section that contains this entry.
podname
filename
line
context
These are just simple accessors that return the value of these properties, as given to the constructor.
pod Extracts the POD for the scope of the entry from $self->filename, beginning at $self->line. For a definition of scope, see Pod::Index.
The POD extraction is delegated to the Pod::Index::Extract module.
VERSION
0.14
SEE ALSO
Pod::Index, Pod::Index::Search, Pod::Index::Extract
AUTHOR
Ivan Tubert-Brohman <itub@cpan.org>
COPYRIGHT
Copyright (c) 2005 Ivan Tubert-Brohman. All rights reserved. This program is free software; you can redistribute it and/or modify it under
the same terms as Perl itself.
perl v5.10.0 2005-10-16 Pod::Index::Entry(3pm)