Find a string and print all lines upto another string
Ok I would like to do the following
file test contains the following lines. between the lines ABC there may be any amount of lines up to the next ABC entry.
I want to grep for the filename.txt entry and print the lines in between (and including that line) up to and including the last line before the next ABC
I want do this so I could also specify filename3.txt and get all 4 lines in between.
All help much appreciated.
any ideas?
---------- Post updated at 04:15 PM ---------- Previous update was at 03:40 PM ----------
Think I've got it
Last edited by rbatte1; 03-11-2015 at 03:01 PM..
Reason: Added CODE tags and corrected spelling and case
I have a textfile containing text similar to the following pattern:
STRING1
UNIQUE_STRING1
STRING2
STRING3
STRING4
STRING5
STRING1
UNIQUE_STRING2
STRING2
STRING3
STRING4
STRING5
STRING1
UNIQUE_STRING3
STRING2
STRING3 (6 Replies)
I have several very large file that are extracts from Oracle tables. These files are formatted in XML type syntax with multiple entries like:
<ROW>
some information
more information
</ROW>
I want to grep for some words, then print all lines between <ROW> AND </ROW>. Can this be done with AWK?... (7 Replies)
I am parsing a nagios config, searching for a string, and then printing the line 2 lines later (the "members" string). Here's the data:
define hostgroup{
hostgroup_name chat-dev
alias chat-dev
members thisisahostname
}
define hostgroup{
... (1 Reply)
What's the easiest way to search a file for a specific string and then look for other instances after that? I want to search for all Virtual Hosts and print out the Server Name and Document Root (if it has that info), while discarding the rest of the info.
Basically my file looks like this:
...... (6 Replies)
i have a file that looks like this
ABC123
aaaaaaaaaaaaaaasssssssssssssssffhhh
ABC234
EMPTY
ABC652
jhfffffffffffffffffffffffffffffffffffkkkkkkkkkkkk
i want to grep "EMPTY" and print ABC234 (3 Replies)
Hi,
I have a file with contents
test id text day
test sah dh dhs
yeay fg jsh jsjk
my need:
I give a string as a input, it check the file and display the lines with the given string
e.g
input : test
output:
test id text day
test sah dh dhs (1 Reply)
RHEL 5.8
I have a text file like below. I want to grep for a string and then print the next 4 lines including the line with the string I grepped for
For eg:
I want grep for the string HANS and then print the next 4 lines including HANS
$ cat someText.txt
JOHN
NATIONALITY:... (7 Replies)
My file has the following contents...
User:SYS,O/SUser:oracle,Process:10813484,Machine:host123.xxx.xxx.xxxxxxx.com.au,Program:sqlplus@host123.xxx.xxx.xxxxxxx.com.au(TNSV1-V,LogonTime:24-JUL-2014
15:04
I would like to print all character appearing after the string LogonTime:
My output... (5 Replies)
Discussion started by: Nagesh_1985
5 Replies
LEARN ABOUT SUNOS
diff3
diff3(1) User Commands diff3(1)NAME
diff3 - 3-way differential file comparison
SYNOPSIS
diff3 [-exEX3] filename1 filename2 filename3
DESCRIPTION
diff3 compares three versions of a file, and publishes disagreeing ranges of text flagged with these codes:
==== all three files differ
====1 filename1 is different
====2 filename2 is different
====3 filename3 is different
The type of change suffered in converting a given range of a given file to some other is indicated in one of these ways:
f : n1 a Text is to be appended after line number n1 in file f, where f = 1, 2, or 3.
f : n1 , n2 c Text is to be changed in the range line n1 to line n2. If n1 = n2, the range may be abbreviated to n1.
The original contents of the range follows immediately after a c indication. When the contents of two files are identical, the contents of
the lower-numbered file is suppressed.
The following command will apply the resulting script to filename1.
(cat script; echo '1,$p') | ed - filename1
OPTIONS -e Produce a script for the ed(1) editor that will incorporate into filename1 all changes between filename2 and filename3 (that is,
the changes that normally would be flagged ==== and ====3).
-x Produce a script to incorporate only changes flagged ====.
-3 Produce a script to incorporate only changes flagged ====3.
-E Produce a script that will incorporate all changes between filename2 and filename3, but treat overlapping changes (that is,
changes that would be flagged with ==== in the normal listing) differently. The overlapping lines from both files will be inserted
by the edit script, bracketed by <<<<<< and >>>>>> lines.
-X Produce a script that will incorporate only changes flagged ====, but treat these changes in the manner of the -E option.
USAGE
See largefile(5) for the description of the behavior of diff3 when encountering files greater than or equal to 2 Gbyte ( 2**31 bytes).
FILES
/tmp/d3*
/usr/lib/diff3prog
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
|Availability |SUNWesu |
|CSI |enabled |
+-----------------------------+-----------------------------+
SEE ALSO diff(1), attributes(5), largefile(5)NOTES
Text lines that consist of a single `.' will defeat -e.
Files longer than 64 Kbytes will not work.
SunOS 5.10 14 Sep 1992 diff3(1)