Sponsored Content
Top Forums Shell Programming and Scripting How to get lines before and after a searched text? Post 302663595 by bbnl on Thursday 28th of June 2012 09:27:38 AM
Old 06-28-2012
Thanks all for helping,

both the solutions are working, sorry asking too much,
is there any way i can get line numbers too along with the output,
Also is there any way i can search based on a certain day.
The reason being. the alert log bloat out and it contains many days of data,
i am planning to run a daily report which collects todays information.
is there anyway i can do this ?
Again sorry i am asking too much here.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to delete first 5 lines and last five lines in all text files

Hi I want to delete first five and last five lines in text files without opening the file and also i want to keep the same file name for all the files. Thanks in advance!!! Ragav (10 Replies)
Discussion started by: ragavendran31
10 Replies

2. Shell Programming and Scripting

how to get lines prior to the line being searched

Hi, Can anbody please let me know how i can retrieve lines above the line being searched in a file. I am looking for an error message from a file, if I see that message I want the lines above that message along with this line. how do we do this. Please do let me know An example which i have... (2 Replies)
Discussion started by: arunrao_oradba
2 Replies

3. Shell Programming and Scripting

[bash help]Adding multiple lines of text into a specific spot into a text file

I am attempting to insert multiple lines of text into a specific place in a text file based on the lines above or below it. For example, Here is a portion of a zone file. IN NS ns1.domain.tld. IN NS ns2.domain.tld. IN ... (2 Replies)
Discussion started by: cdn_humbucker
2 Replies

4. Shell Programming and Scripting

Print lines between two lines after grep for a text string

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)
Discussion started by: jbruce
7 Replies

5. Shell Programming and Scripting

sed show lines text between 2 blank lines

I have a file like blah blah blah blah this is the text I need, which might be between 1-4 lines, but always has a blank line above and below it, and is at the end of the text file the code tags don't show the trailing blank line. I started by deleting the last blank line with: ... (2 Replies)
Discussion started by: unclecameron
2 Replies

6. Shell Programming and Scripting

Read n lines from a text files getting n from within the text file

I dont even have a sample script cause I dont know where to start from. My data lookes like this > sat#16 #data: 15 site:UNZA baseline: 205.9151 0.008 -165.2465 35.8109 40.6685 21.9148 121.1446 26.4629 -18.4976 33.8722 0.017 -165.2243 48.2201 40.6908 ... (8 Replies)
Discussion started by: malandisa
8 Replies

7. Shell Programming and Scripting

Search String and extract few lines under the searched string

Need Assistance in shell programming... I have a huge file which has multiple stations and i wanted to search particular station and extract few lines from it and the rest is not needed Bold letters are the stations . The whole file has multiple stations . Below example i wanted to search... (4 Replies)
Discussion started by: ajayram_arya
4 Replies

8. Shell Programming and Scripting

awk to skip lines find text and add text based on number

I am trying to use awk skip each line with a ## or # and check each line after for STB= and if that value in greater than or = to 0.8, then at the end of line the text "STRAND BIAS" is written in else "GOOD". So in the file of 4 entries attached. awk tried: awk NR > "##"' "#" -F"STB="... (6 Replies)
Discussion started by: cmccabe
6 Replies

9. Shell Programming and Scripting

Match text to lines in a file, iterate backwards until text or text substring matches, print to file

hi all, trying this using shell/bash with sed/awk/grep I have two files, one containing one column, the other containing multiple columns (comma delimited). file1.txt abc12345 def12345 ghi54321 ... file2.txt abc1,text1,texta abc,text2,textb def123,text3,textc gh,text4,textd... (6 Replies)
Discussion started by: shogun1970
6 Replies

10. UNIX for Beginners Questions & Answers

Insert text after the first occurance of searched string entry in a file

My server xml file has huge data part of which i'm sharing below. I wish to add the below text held by variable "addthisline" after the closing braces i.e --> once the first </Connector> tag is found. addthisline="I need to be inserted after the comments" Thus my searchstring is... (3 Replies)
Discussion started by: mohtashims
3 Replies
MAN.CONF(5)						      BSD File Formats Manual						       MAN.CONF(5)

NAME
man.conf -- configuration file for manual pages DESCRIPTION
The man.conf file contains the default configuration used by man(1), apropos(1), whatis(1), catman(8), and makewhatis(8) to find manual pages and information about manual pages (e.g. the whatis database). Manual pages are located by searching an ordered set of directories called the ``man path'' for a file that matches the name of the requested page. Each directory in the search path usually has a set of subdirectories in it (though this is not required). When subdirectories are used, there are normally two subdirectories for each section of the manual. One subdirectory contains formatted copies of that section's manual pages that can be directly displayed to a terminal, while the other section subdirectory contains unformatted copies of the pages (see nroff(1) and mdoc(7)). Formatted manual pages are normally named with a trailing ``.0'' suffix. The man.conf file contains comment and configuration lines. Comment lines start with the ``#'' character. Blank lines are also treated as comment lines. Configuration lines consist of a configuration keyword followed by a configuration string. There are two types of configura- tion keywords: control keywords and section keywords. Control keywords must start with the ``_'' character. The following control keywords are currently defined: _build identifies the set of suffixes used for manual pages that must be formatted for display and the command that should be used to for- mat them. Manual file names, regardless of their format, are expected to end in a ``.*'' pattern, i.e. a ``.'' followed by some suffix. The first field of a _build line contains a man page suffix specification. The suffix specification may contain the nor- mal shell globbing characters (NOT including curly braces (``{}'')). The rest of the _build line is a shell command line whose standard output is a formatted manual page that can be directly displayed to the user. There should be exactly one occurrence of the string ``%s'' in the shell command line, and it will be replaced by the name of the file which is being formatted. _crunch used by catman(8) to determine how to crunch formatted pages which originally were compressed man pages: The first field lists a suffix which indicates what kind of compression were used to compress the man page. The rest of the line must be a shell command line, used to compress the formatted pages. There should be exactly one occurrence of the string ``%s'' in the shell command line, and it will be replaced by the name of the output file. _default contains the system-wide default man path used to search for man pages. _subdir contains the list (in search order) of section subdirectories which will be searched in any man path directory named with a trail- ing slash (``/'') character. This list is also used, even if there is no trailing slash character, when a path is specified to the man(1) utility by the user, by the MANPATH environment variable, or by the -M and -m options. _suffix identifies the set of suffixes used for formatted man pages (the ``.0'' suffix is normally used here). Formatted man pages can be directly displayed to the user. Each suffix may contain the normal shell globbing characters (NOT including curly braces (``{}'')). _version contains the version of the configuration file. _whatdb defines the full pathname (not just a directory path) for a database to be used by the apropos(1) and whatis(1) commands. The pathname may contain the normal shell globbing characters, including curly braces (``{}''); to escape a shell globbing character, precede it with a backslash (``''). Section configuration lines in man.conf consist of a section keyword naming the section and a configuration string that defines the directory or subdirectory path that the section's manual pages are located in. The path may contain the normal shell globbing characters, including curly braces (``{}''); to escape a shell globbing character, precede it with a backslash (``''). Section keywords must not start with the ``_'' character. A section path may contain either a list of absolute directories or a list of or relative directories (but not both). Relative directory paths are treated as a list of subdirectories that are appended to the current man path directory being searched. Section configuration lines with absolute directory paths (starting with ``/'') completely replace the current man search path directory with their content. Section configuration lines with absolute directory paths ending with a trailing slash character are expected to contain subdirectories of manual pages, (see the keyword ``_subdir'' above). The ``_subdir'' subdirectory list is not applied to absolute section directories if there is no trailing slash. In addition to the above rules, the man(1) command also always checks in each directory that it searches for a subdirectory with the same name as the current machine type. If the machine-specific directory is found, it is also searched. This allows the manual to contain machine-specific man pages. Note that the machine subdirectory does not need to be specified in the man.conf file. Multiple specifications for all types of man.conf configuration lines are cumulative and the entries are used in the order listed in the file; multiple entries may be listed per line, as well. FILES
/etc/man.conf Standard manual configuration file. EXAMPLES
Given the following man.conf file: _version BSD.2 _subdir cat[123] _suffix .0 _build .[1-9] nroff -man %s _build .tbl tbl %s | nroff -man _default /usr/share/man/ sect3 /usr/share/man/{old/,}cat3 By default, the command ``man mktemp'' will search for ``mktemp.<any_digit>'' and ``mktemp.tbl'' in the directories ``/usr/share/man/cat1'', ``/usr/share/man/cat2'', and ``/usr/share/man/cat3''. If on a machine of type ``vax'', the subdirectory ``vax'' in each directory would be searched as well, before the directory was searched. If ``mktemp.tbl'' was found first, the command ``tbl <manual page> | nroff -man'' would be run to build a man page for display to the user. The command ``man sect3 mktemp'' would search the directories ``/usr/share/man/old/cat3'' and ``/usr/share/man/cat3'', in that order, for the mktemp manual page. If a subdirectory with the same name as the current machine type existed in any of them, it would be searched as well, before each of them were searched. SEE ALSO
apropos(1), machine(1), man(1), whatis(1), whereis(1), fnmatch(3), glob(3), catman(8), makewhatis(8) BSD
December 27, 2011 BSD
All times are GMT -4. The time now is 07:13 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy