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 CENTOS
lsdiff
LSDIFF(1) Man pages LSDIFF(1)
NAME
lsdiff - show which files are modified by a patch
SYNOPSIS
lsdiff [[-n] | [--line-number]] [[-p n] | [--strip-match=n]] [--strip=n] [--addprefix=PREFIX] [[-s] | [--status]] [[-E] |
[--empty-files-as-removed]] [[-i PATTERN] | [--include=PATTERN]] [[-x PATTERN] | [--exclude=PATTERN]] [[-z] | [--decompress]]
[[-# RANGE] | [--hunks=RANGE]] [--lines=RANGE] [--files=RANGE] [[-H] | [--with-filename]] [[-h] | [--no-filename]] [[-v] |
[--verbose]...] [file...]
lsdiff {[--help] | [--version] | [--filter ...] | [--grep ...]}
DESCRIPTION
List the files modified by a patch.
You can use both unified and context format diffs with this program.
OPTIONS
-n, --line-number
Display the line number that each patch begins at. If verbose output is requested (using -nv), each hunk of each patch is listed as
well.
For each file that is modified, a line is generated containing the line number of the beginning of the patch, followed by a Tab
character, followed by the name of the file that is modified. If -v is given once, following each of these lines will be one line for
each hunk, consisting of a Tab character, the line number that the hunk begins at, another Tab character, the string "Hunk #", and the
hunk number (starting at 1).
If the -v is given twice in conjunction with -n (i.e. -nvv), the format is slightly different: hunk-level descriptive text is shown
after each hunk number, and the --number-files option is enabled.
--number-files
File numbers are listed, beginning at 1, before each filename.
-# RANGE, --hunks=RANGE
Only list hunks within the specified RANGE. Hunks are numbered from 1, and the range is a comma-separated list of numbers or
"first-last" spans; either the first or the last in the span may be omitted to indicate no limit in that direction.
--lines=RANGE
Only list hunks that contain lines from the original file that lie within the specified RANGE. Lines are numbered from 1, and the range
is a comma-separated list of numbers or "first-last" spans; either the first or the last in the span may be omitted to indicate no
limit in that direction.
--files=RANGE
Only list files indicated by the specified RANGE. Files are numbered from 1 in the order they appear in the patch input, and the range
is a comma-separated list of numbers or "first-last" spans; either the first or the last in the span may be omitted to indicate no
limit in that direction.
-p n, --strip-match=n
When matching, ignore the first n components of the pathname.
--strip=n
Remove the first n components of the pathname before displaying it.
--addprefix=PREFIX
Prefix the pathname with PREFIX before displaying it.
-s, --status
Show file additions, modifications and removals. A file addition is indicated by a "+", a removal by a "-", and a modification by a
"!".
-E, --empty-files-as-removed
Treat empty files as absent for the purpose of displaying file additions, modifications and removals.
-i PATTERN, --include=PATTERN
Include only files matching PATTERN.
-x PATTERN, --exclude=PATTERN
Exclude files matching PATTERN.
-z, --decompress
Decompress files with extensions .gz and .bz2.
-H, --with-filename
Print the name of the patch file containing each patch.
-h, --no-filename
Suppress the name of the patch file containing each patch.
-v, --verbose
Verbose output.
--help
Display a short usage message.
--version
Display the version number of lsdiff.
--filter
Behave like filterdiff(1) instead.
--grep
Behave like grepdiff(1) instead.
SEE ALSO
filterdiff(1), grepdiff(1)
EXAMPLES
To sort the order of touched files in a patch, you can use:
lsdiff patch | sort -u |
xargs -rn1 filterdiff patch -i
To show only added files in a patch:
lsdiff -s patch | grep '^+' |
cut -c2- | xargs -rn1 filterdiff patch -i
To show the headers of all file hunks:
lsdiff -n patch | (while read n file
do sed -ne "$n,$(($n+1))p" patch
done)
AUTHOR
Tim Waugh <twaugh@redhat.com>
Package maintainer
patchutils 23 Jan 2009 LSDIFF(1)