Sponsored Content
Top Forums Shell Programming and Scripting Search for string and print top and bottom line Post 302554866 by bombcan on Tuesday 13th of September 2011 08:21:17 AM
Old 09-13-2011
Search for string and print top and bottom line

Hi Folks

I need a one liner to parse through a log and if the string is found print the line above, the line with the string and the line below.

example:

The ball is green and blue
Billy through the ball higer.
Jane got hurt with the ball.

So if I search for Billy I would need the 3 lines above printed.

Thanks
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to search for a pattern from bottom to top.

Hi, I have a file, which is having a pattern "SEARCH" somewhere towards end of the file, if i am giving " grep -i "SEARCH" $File" , it is taking too much time as file is very big. So i want to search for the pattern from the back side of the file, how can we search for a pattern in bottom... (5 Replies)
Discussion started by: Prat007
5 Replies

2. Shell Programming and Scripting

How to use sed to search for string and Print previous two lines and current line

Hello, Can anybody help me to correct my sed syntax to find the string and print previous two lines and current line and next one line. i am using string as "testing" netstat -v | sed -n -e '/test/{x;2!p;g;$!N;p;D;}' -e h i am able to get the previous line current line next line but... (1 Reply)
Discussion started by: nmadhuhb
1 Replies

3. Shell Programming and Scripting

Search a string and print the rest of line

Hi Guys, I need to search a string and print the rest of the lines... input: 8 0 90 1 0 59 20 2488 96 30006dde372 S ? 0:00 /etc/opt/SUNWconn/atm/bin/atmsnmpd -n output: 00 /etc/opt/SUNWconn/atm/bin/atmsnmpd -n Actually i don even need the first "00".. any suggestions is appreciated..... (13 Replies)
Discussion started by: mac4rfree
13 Replies

4. Shell Programming and Scripting

awk print second line after search string

I have multiple config files where I need to pull the ip address from loopback3. The format is the same in every file, the ip is the second line after interface loopback3. interface loopback2 loopback description router ID ip address 192.168.1.1 interface loopback3 loopback description... (3 Replies)
Discussion started by: numele
3 Replies

5. Shell Programming and Scripting

Print lines after the search string until blank line is found

All I want is to look for the pattern in the file...If I found it at # places... I want print lines after those pattern(line) until I find a blank line. Log EXAMPLE : MT:Exception caught The following Numbers were affected: 1234 2345 2346 Error java.lang.InternalError:... (3 Replies)
Discussion started by: prash184u
3 Replies

6. Shell Programming and Scripting

Search string and print the above line and below lines?.

if the first string matches then print the previous line and current line and also print the following lines if the other string search matches. Input ------ TranTime 2012 10 12 The Record starts here Accountnumber: 4632473431274 TxnCode 323 TranID 329473242834 ccsdkcnsdncskd... (7 Replies)
Discussion started by: laknar
7 Replies

7. Shell Programming and Scripting

String search and print next all lines in one line until blank line

Dear all I want to search special string in file and then print next all line in one line until blank lines come. Help me plz for same. My input file and desire op file is as under. i/p file: A1/EXT "BSCABD1_21233G1" 757 130823 1157 RADIO X-CEIVER ADMINISTRATION BTS EXTERNAL FAULT ... (7 Replies)
Discussion started by: jaydeep_sadaria
7 Replies

8. Shell Programming and Scripting

Print n lines from top and n lines from bottom of all files with .log extenstion

Oracle Linux 6.4 In a directory I have more than 300 files with the extension .log I want the first 5 and last 5 lines of these .log files to be printed on screen with each file's name. Expected output : Printing first 5 and last 5 lines of FX_WT_Feb8_2014.log !! Authentication... (7 Replies)
Discussion started by: kraljic
7 Replies

9. Shell Programming and Scripting

How to print from bottom to top?

Hi, i have a file which contains PID and wanted to execute kill command. but the thing is, when killing PID's needs to kill PID from bottom to top. Please help INPUT 21414 sh -c extract.ksh ASA 21416 /bin/ksh extract.ksh ASA 21428 /usr/bin/perl -w /var/tmp/tempperl.21416 ASA... (4 Replies)
Discussion started by: reignangel2003
4 Replies

10. Shell Programming and Scripting

Grep command to search a regular expression in a line an only print the string after the match

Hello, one step in a shell script i am writing, involves Grep command to search a regular expression in a line an only print the string after the match an example line is below /logs/GRAS/LGT/applogs/lgt-2016-08-24/2016-08-24.8.log.zip:2016-08-24 19:12:48,602 ERROR... (9 Replies)
Discussion started by: Ramneekgupta91
9 Replies
kball(6)							       Games								  kball(6)

NAME
kball - a game of skill and reflexes for all the family SYNOPSIS
kball [-w] [-bppXX] [-mapeditor] [-trace] DESCRIPTION
KBall is a game of skill and reflexes, non violent, suitable for all ages. The idea is to move a ball around the map, without falling, without running out of time, and getting the prizes, in order to reach the exit. The map has different traps, such as slides, pushers, jumps, falls, walls, etc. Maps are viewed from top view, and the walls and player's ball are real-time rendered in beautiful 3D. It is 100% non-violent FUN - Suitable for ALL ages. Also, a easy to use, full map editor is included, so you can do your OWN maps! USAGE
You must guide your crystal ball in the labyrinth, without falling from it, without running out of time, and picking up the ying-yang power ups, in order to exit the labyrinth reaching the floor marked with the ying-yang mark. Besides the ying-yang power ups, there are other prizes that will have different effects on the score. KEYS
Some keys that you can use during the game: Key Effect ESC Ends the game P PAUSE Pause the game F12 Save a screen-shoot TIPS
You don't need to pick up all the prizes to exit, only the ying-yang, but you may desire to get all the prizes to get a better score. Always keep and eye on remaining time. There are secret zones in some labyrinths. Look for them. In some levels, there are secret shortcuts. In some places, there are fake walls, you can go thought them and reach secret places. You can move your ball in the middle of the air, use this to do cool jumps. Is better to do multiple jumps at once, using your ability to move the ball in the air to perfect the multi-jump. You can use a combination of controllers to move the ball (like mouse + keyboard for example). When you be ready to exit the level, you will see the word "EXIT" flashing at upper right. Don't try to exit the level if you don't see that word. Use the map editor to do your own custom maps. The new levels must be saved inside the "levels" folder inside the installation folder of Kball. Pressing <F1> in the map editor you will see a list with all the available commands. OPTIONS
These command line options are available: -w Runs the game in a window. -f Runs the game in a full screen. -nosound Disables music and sound system. -bpp16 Selects a 16 bits color depth. -bpp15 Selects a 15 bits color depth. -bpp32 Selects a 32 bits color depth. -bpp24 Selects a 24 bits color depth. -mapeditor Starts only the map editor. -trace Enables the debugging tracer, only useful for the developers of the game, or to report bugs. AUTHOR
The original program was written by Kronoman. This manual page was written for the Debian GNU/Linux system by Miriam Ruiz <little_miry@yahoo.es> (but may be used by others, of course) Miriam Ruiz 06.04.2005 kball(6)
All times are GMT -4. The time now is 05:12 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy