02-20-2020
If it's not a big file, you can get a simple to understand but clunky way by using the output of grep -n "start" $filename and grep -n "end" $filename to get you the record numbers to search between and then perhaps a sed -n "$start_line,$end_line"p $filename
This would be slow with a very large file though because you would read it all three times.
Does this help, or is your file big enough to warrant a solution that just reads it once?
Kind regards,
Robin
10 More Discussions You Might Find Interesting
1. Programming
Sir,
I want to check for the repation of a user address in a file i used || as my delimiter and want to check repetaip0n of the address that is mailid and then i have to use IMAP and all.
How can i do this...
I am in linux ...and my file is linux file.
... (5 Replies)
Discussion started by: arunkumar_mca
5 Replies
2. Shell Programming and Scripting
Hi all
I have a file with below content (content is variable whenever new product is launched). I need form a grep command like this
egrep "Unknown product|Invalid symboland so on"
How to do it using a script?
Unknown product
Invalid symbol
No ILX exch found
exceeds maximum size
AFX... (4 Replies)
Discussion started by: johnl
4 Replies
3. Shell Programming and Scripting
Hi all,
I'm looking for some help. I have a file (very long) that is organized like below:
>Cluster 0
0 283nt, >01_FRYJ6ZM12HMXZS... at +/99%
1 279nt, >01_FRYJ6ZM12HN12A... at +/99%
2 281nt, >01_FRYJ6ZM12HM4TS... at +/99%
3 283nt, >01_FRYJ6ZM12HM946... at +/99%
4 279nt,... (4 Replies)
Discussion started by: d.chauliac
4 Replies
4. Shell Programming and Scripting
I hava a file with following data:
number|CREDIT_ID|NULL
date|SYS_CREATION_DATE|NULL
varchar2|GGS_COMMIT_CHAR|NULL
varchar2|GGS_OP_TYPE|NULL
number|GGS_SCN|NULL|
number|GGS_LOG_SEQ|NULL
number|GGS_LOG_POS|NULL
number|GGS_ORACREC_SCN|NULL
varchar2|BATCH_ID|NULL
char|GGS_IMAGE_TYPE|NULL
... (6 Replies)
Discussion started by: kolesunil
6 Replies
5. Shell Programming and Scripting
Hi,
I am trying to locate the occurences of certain pattern like 'Possible network disconnect' in a text file. I can get the actual lines matching the pttern using:
grep -w 'Possible network disconnect' file_name.
But I am more interested in getting the timing of these events which are... (7 Replies)
Discussion started by: sagarparadkar
7 Replies
6. UNIX for Dummies Questions & Answers
Dear all,
Greetings.
I would like to ask for your help to extract lines with specific words in addition 2 lines before and after these lines by using awk or sed.
For example, the input file is:
1 ak1 abc1.0
1 ak2 abc1.0
1 ak3 abc1.0
1 ak4 abc1.0
1 ak5 abc1.1
1 ak6 abc1.1
1 ak7... (7 Replies)
Discussion started by: Amanda Low
7 Replies
7. Shell Programming and Scripting
Hello dear Unix shell professionals,
I am desperately trying to get a seemingly simple logic to work. I need to extract words from a text line and save them in an array. The text can look anything like that:
aaaaaaa${important}xxxxxxxx${important2}ooooooo${importantstring3}...I am handicapped... (5 Replies)
Discussion started by: Grünspanix
5 Replies
8. Shell Programming and Scripting
'Hi
I'm using the following code to extract the lines(and redirect them to a txt file) after the pattern match. But the output is inclusive of the line with pattern match.
Which option is to be used to exclude the line containing the pattern?
sed -n '/Conn.*User/,$p' > consumers.txt (11 Replies)
Discussion started by: essem
11 Replies
9. UNIX for Dummies Questions & Answers
Hi all!
Thanks for taking the time to view this!
I want to grep out all lines of a file that starts with pattern 1 but also does not match with the second pattern.
Example:
Drink a soda
Eat a banana
Eat multiple bananas
Drink an apple juice
Eat an apple
Eat multiple apples
I... (8 Replies)
Discussion started by: demmel
8 Replies
10. Shell Programming and Scripting
Hello,
I have two files. All urls are space seperated.
source
http://xx.yy.zz http://df.ss.sd.xz http://09.09.090.01
http://11.22.33 http://canada.xx.yy http://01.02.03.04
http://33.44.55 http://98.87.76.65 http://russia.xx.zz
http://aa.tt.xx.zz http://1w.2e.3r.4t http://china.rr.tt
... (4 Replies)
Discussion started by: baris35
4 Replies
LEARN ABOUT DEBIAN
pdfgrep
pdfgrep(1) USER COMMANDS pdfgrep(1)
NAME
pdfgrep - search pdf files for a regular expression
SYNOPSIS
pdfgrep [OPTION...] PATTERN FILE...
DESCRIPTION
Search for PATTERN in each FILE. PATTERN is an extended regular expression.
pdfgrep works much like grep, with one distinction: It operates on pages and not on lines.
OPTIONS
-i, --ignore-case
Ignore case distinctions in both the PATTERN and the input files.
-H, --with-filename
Print the file name for each match. This is the default setting when there is more than one file to search.
-h, --no-filename
Suppress the prefixing of file name on output. This is the default setting when there is only one file to search.
-n, --page-number
Prefix each match with the number of the page where it was found.
-c, --count
Suppress normal output. Instead print the number of matches for each input file. Note that unlike grep, multiple matches on the same
page will be counted individually.
-C, --context NUM
Print at most NUM characters of context around each match. The exact number will vary, because pdfgrep tries to respect word bound-
aries. If NUM is "line", the whole line will be printed. If this option is not set, pdfgrep tries to print lines that are not longer
than the terminal width.
--color WHEN
Surround file names, page numbers and matched text with escape sequences to display them in color on the terminal. (The default set-
ting is auto).
WHEN can be:
always Always use colors, even when stdout is not a terminal.
never Do not use colors.
auto Use colors only when stdout is a terminal.
-R, -r, --recursive
Recursively search all files (restricted by --include and --exclude) under each directory.
--exclude=GLOB
Skip files whose base name matches GLOB. See glob(7) for wildcards you can use. You can use this option multiple times to exclude
more patterns. It takes precedence over --include. Note, that in- and excludes apply only to files found via --recursive and not to
the argument list.
--include=GLOB
Only search files whose base name matches GLOB. See --exclude for details. The default is *.pdf.
--unac Remove accents and ligatures from both the search pattern and the PDF documents. This is useful if you want to search for a word
containing 'ae', but the PDF uses the single character 'ae' instead. See unac(3) and unaccent(1) for details.
[This option is experimental and only available if pdfgrep is compiled with unac support.]
-q, --quiet
Suppress all normal output to stdout. Errors will be printed and the exit codes will be returned (see below).
--help Print a short summary of the options.
-V, --version
Show version information
ENVIRONMENT VARIABLES
The behavior of pdfgrep is affected by the following environment variable.
GREP_COLORS
Specifies the colors and other attributes used to highlight various parts of the output. The syntax and values are like GREP_COLORS
of grep. See grep(1) for more details. Currently only the capabilities mt, ms, mc, fn, ln and se are used by pdfgrep, where mt, ms
and mc have the same effect on pdfgrep.
EXIT STATUS
Normally, the exit status is 0 if at least one match is found, 1 if no match is found and 2 if an error occurred. But if the --quiet or -q
option is used and a match was found, pdfgrep will return 0 regardless of errors.
AUTHOR
Hans-Peter Deifel <hpdeifel at gmx.de>
SEE ALSO
grep(1), regex(7)
version 1.2 February 14, 2012 pdfgrep(1)