egrep 4th line from match


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting egrep 4th line from match
Prev   Next
# 1  
Old 05-10-2010
Data egrep 4th line from match

Can some one help me to print 4th line before the match using egrep or grep command options.
i have a very large file and i need to search the entire file, look for the match (key word) and print 4th line before the matched key word.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Egrep patterns in a file and limit number of matches to print for each pattern match

Hi I need to egrep patterns in a file and limit number of matches to print for each matched pattern. -m10 option is not working out in my sun solaris 5.10 Please guide me the options to achieve. if i do head -10 , i wont be getting all pattern match results as output since for a... (10 Replies)
Discussion started by: ananan
10 Replies

2. Shell Programming and Scripting

Egrep - Only Match First Occurrence

echo 'String#1 and String#2' | egrep -o -m 1 'String#.{1}' String#1 String#2 I'm trying to just match the first occurrence of 'String#' + 1 character. I thought the "-m 1" switch would do that for me. Instead I get both occurrences. Can somebody provide some insight? Thanks! (5 Replies)
Discussion started by: sudo
5 Replies

3. Shell Programming and Scripting

Reading in 4th number in a line

I'd like to read a file (mydata.dat) line by line. The file consists of 5 columns filled with numbers, like so: 83.018 1.953 49.587 20550.000 353 83.213 1.953 49.195 20600.000 171 84.935 1.954 48.803 20650.000 920 For every read line (i.e. in every... (2 Replies)
Discussion started by: pina
2 Replies

4. Shell Programming and Scripting

Match pattern1 in file, match pattern2, substitute value1 in line

not getting anywhere with this an xml file contains multiple clients set up with same tags, different values. I need to parse the file for client foo, and change the value of tag "64bit" from false to true. cat clients.xml <Client type"FIX"> <ClientName>foo</ClientName>... (3 Replies)
Discussion started by: jack.bauer
3 Replies

5. Shell Programming and Scripting

Escaping backslash and asterisk in egrep to match "\*"

So far what i've got is egrep '^(\\)\*$'No luck. I've searched the web and not much luck. I know about the escape character \ but its confusing to figure out how to use it to match a backslash and use it to escape the asterisk also. Any ides? Thanks! (8 Replies)
Discussion started by: matthewfs
8 Replies

6. Shell Programming and Scripting

Perl match multiple numbers from a variable similar to egrep

I want to match the number exactly from the variable which has multiple numbers seperated by pipe symbol similar to search in egrep.below is the code which i tried #!/usr/bin/perl my $searchnum = $ARGV; my $num = "148|1|0|256"; print $num; if ($searchnum =~ /$num/) { print "found"; }... (2 Replies)
Discussion started by: kar_333
2 Replies

7. Shell Programming and Scripting

1st column,2nd column on first line 3rd,4th on second line ect...

I need to take one column of data and put it into the following format: 1st line,2nd line 3rd line,4th line 5th line,6th line ... Thanks! (6 Replies)
Discussion started by: batcho
6 Replies

8. UNIX for Dummies Questions & Answers

retrieve every 4th line from a file

Hello, I want to retrieve 2, 6, 10, 14...... (each 4 lines apart) from a file that looks like the sample below. In other words, I want only lines corresponding to the Xs. Header1_a XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Header1_b yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy Header2_a... (2 Replies)
Discussion started by: Gussifinknottle
2 Replies

9. Shell Programming and Scripting

How to replace all after 4th character in line ?

How to replace all after 4 character at line? & convert to upper case ? google.com -> GOOG (2 Replies)
Discussion started by: Trump
2 Replies

10. UNIX for Dummies Questions & Answers

query on how to search for a line and read 4th word from that line

Assume I have a text file as below: me con pi ind ken pras ur me con rome ind kent pras urs pintu con mys ind pan pras ki con kit ind sys My requirement, I need to search for "con rome" and if exists, then print 4th word from rome, i.e in above example, since "con rome"... (4 Replies)
Discussion started by: jaggesh
4 Replies
Login or Register to Ask a Question
VERSION.4TH(8)						    BSD System Manager's Manual 					    VERSION.4TH(8)

NAME
version.4th -- FreeBSD version string boot module DESCRIPTION
The file that goes by the name of version.4th is a set of commands designed to draw the boot loader version at the bottom-right of the screen. The commands of version.4th by themselves are not enough for most uses. Please refer to the examples below for the most common sit- uations, and to loader(8) for additional commands. Before using any of the commands provided in version.4th, it must be included through the command: include version.4th This line is present in the default /boot/menu.rc file, so it is not needed (and should not be re-issued) in a normal setup. The commands provided by it are: print_version Prints the contents of the loader_version environment variable right-justified at the column loader_version_x and row loader_version_y. The environment variables that effect its behavior are: loader_version Set automatically by loader(8), but you can override it by setting in loader.conf(5). This should be the version of boot loader used. loader_version_x Sets the desired ending column position of loader_version. Default is 80. loader_version_y Sets the desired ending row position of loader_version. Default is 24. loader_color If set to ``NO'' (case-insensitive) or ``0'', causes the version to be printed without color (default is ANSI Cyan). FILES
/boot/loader The loader(8). /boot/version.4th version.4th itself. /boot/loader.rc loader(8) bootstrapping script. EXAMPLES
Override loader(8) version in loader.conf(5): loader_version="loader 1.1" SEE ALSO
loader.conf(5), color.4th(8), loader(8) HISTORY
The version.4th set of commands first appeared in FreeBSD 9.0. AUTHORS
The version.4th set of commands was written by Devin Teske <dteske@FreeBSD.org>. BSD
August 6, 2013 BSD