01-21-2008
grep -n lines before and after
Hi,
is it possible to grep a pattern that will include the "n" lines before and after the line where the pattern have been found?
e.g.
#this contains the test.file
line1
line2
line3
line4
line5
then a grep command to search the word "line3"
and the output should be 1 (or n) line before that line and 1 (or n) line "after" that line.
dessired output of the grep command
line2
line3
line4
Thanks in advance.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hello again, I'm still working on the redo of my script I created before and came across a grep question.
I'm on SunOS 5.9 and using the Korn Shell. I'm writing a function to check for validation of root disks being mirrored. If the server allows me to use metastat, I'm looking to show it has... (4 Replies)
Discussion started by: Janus
4 Replies
2. Shell Programming and Scripting
suppose i have a file structure(serial file)--
----------
----------
---------
summery
--------
------
--------
finished
-----
-------
i want to fetch lines from summery to finished
i can get line of summery by grep command. but how can i fetch lines untill it reaches finished.probably... (2 Replies)
Discussion started by: arghya_owen
2 Replies
3. Shell Programming and Scripting
Hi
I am writing a script which should read a file and search for certain strings 'approved' or 'removed' and retain only those lines that contain the above strings.
Ex: file name 'test'
test:
approved package
waiting for approval package
disapproved package
removed package
approved... (14 Replies)
Discussion started by: vj8436
14 Replies
4. Shell Programming and Scripting
Hi folks
I am not allowed to install GNU grep on AIX.
Here my code excerpt:
grep_fatal () {
/usr/sfw/bin/gegrep -B4 -A2 "FATAL|QUEUE|SIGHUP"
}
Howto the same on AIX based machine?
from manual GNU grep
‘--after-context=num’
Print num lines of trailing context after... (4 Replies)
Discussion started by: slashdotweenie
4 Replies
5. Shell Programming and Scripting
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
6. Shell Programming and Scripting
Hi,
my xml files looks something like this
<Instance Name="New York">
<Description></Description>
<Instance Name="A">
<Description></Description>
<PropertyValue Key="false" Name="Building A" />
</Instance>
<Instance Name="B">
... (4 Replies)
Discussion started by: tententen
4 Replies
7. Shell Programming and Scripting
Hi,
I have one file, say file 1, that has data like below where 19900107 is the date,
19900107 12 144 129 0.7380047
19900108 12 168 129 0.3149017
19900109 12 192 129 3.2766666E-02
... (3 Replies)
Discussion started by: Wynner
3 Replies
8. Shell Programming and Scripting
I have an input file
12.4 1.72849432773174e+01 -7.74784188610632e+01
12.5 9.59432114416327e-01 -7.87018212757537e+01
15.6 5.20139995965960e-01 -5.61612429666624e+01
29.3 3.76696387248366e+00 -7.42896194101892e+01
32.1 1.86899877018077e+01 -7.56508762501408e+01
35 6.98857157014640e+00... (2 Replies)
Discussion started by: chrisjorg
2 Replies
9. Shell Programming and Scripting
Hello,
I want to extract from a file like :
20120530025502914 | REQUEST | whatever
20120530025502968 | RESPONSE | whatever
20120530025502985 | RESPONSE | whatever
20120530025502996 | REQUEST | whatever
20120530025503013 | REQUEST | whatever
20120530025503045 | RESPONSE | whatever
I want... (14 Replies)
Discussion started by: black_fender
14 Replies
10. Shell Programming and Scripting
say we have :
2914 | REQUEST | whatever
2914 | RESPONSE | whatever
2914 | SUCCESS | whatever
2985 | RESPONSE | whatever
2986 | REQUEST | whatever
2990 | REQUEST | whatever
2985 | RESPONSE | whatever
2996 | REQUEST | whatever
2010 | SUCCESS | whatever
2013 | REQUEST | whatever
2013 |... (7 Replies)
Discussion started by: Saumitra Pandey
7 Replies
LEARN ABOUT OPENSOLARIS
cam
cam(1) General Commands Manual cam(1)
NAME
cam - CPU'S AUDIO MIXER for Linux
SYNOPSIS
cam [-v x,y] [--volume x,y] [-b x,y] [--bass x,y] [-t x,y] [--treble x,y] [-s x,y] [--synth x,y] [-p x,y] [--pcm x,y] [-S x,y]
[--speaker x,y] [-l x,y] [--line x,y] [-m x,y] [--mic x,y] [-c x,y] [--cd x,y] [-M x,y] [--mixer x,y] [-a x,y] [--altpcm x,y] [-r
x,y] [--reclev x,y] [-i x,y] [--igain x,y] [-o x,y] [--ogain x,y] [-l1 x,y] [--line1 x,y] [-l2 x,y] [--line2 x,y] [-l3 x,y] [--line3
x,y] [-3d 1|0] [--3dse 1|0] [-agc 1|0] [--agc 1|0] [-h] [-?] [--help] [-get] [-save] [-getfile filename] [-savefile filename]
xcam
DESCRIPTION
This is an audio mixer for Linux. You have the choice to use it with an interface or at the command line.
OPTIONS
When using the interface you can use the following keys :
LEFT ARROW
decrease the volume of the current device.
RIGHT ARROW
increase the volume of the current device.
UP ARROW
go to previous device.
DOWN ARROW
go to next device.
L locks or unlocks :
unlocked : you can control the left and right channel
separately.
lock : left and right channel are controlled together.
R turn on/off recording mode :
red lamp : recording turned on
green lamp : recording turned off
3 turn on/off 3D Stereo Enhancement (3DSE) device :
when turned on green indicator 3D will be lit at the left side of main volume handle.
A turn on/off microphone Automatic Gain Control :
when turned on green indicator AGC will be lit at the left side of microphone volume handle.
S save the settings of ALL devices in a file ($HOME/.camrc)
G loads the saved settings and restores them.
H shows the help screen.
Q/ESC exits the program and returns to shell.
NOTE: you can use upper or lower case.
When using the command line options the interface is not shown.
The following options are available :
-v, --volume x,y
Set 'volume' to x (left) and y (right)
-b, --bass x,y
Set 'bass' to x (left) and y (right)
-t, --trebble x,y
Set 'treble' to x (left) and y (right)
-s, --synth x,y
Set 'synth' to x (left) and y (right)
-p, --pcm x,y
Set 'pcm' to x (left) and y (right)
-S, --speaker x,y
Set 'speaker' to x (left) and y (right)
-l, --line x,y
Set 'line in' to x (left) and y (right)
-m, --mic x,y
Set 'microphone' to x (left) and y (right)
-c, --cd x,y
Set 'CD in' to x (left) and y (right)
-I, --imix x,y
Set 'mixer' to x (left) and y (right)
-a, --altpcm x,y
Set 'altpcm' to x (left) and y (right)
-r, --reclev x,y
Set 'record level' to x (left) and y (right)
-i, --igain x,y
Set 'input gain' to x (left) and y (right)
-o, --ogain x,y
Set 'output gain' to x (left) and y (right)
-l1, --line1 x,y
Set 'line 1' to x (left) and y (right)
-l2, --line2 x,y
Set 'line 2' to x (left) and y (right)
-l3, --line3 x,y
Set 'line 3' to x (left) and y (right)
-3d, --3dse 1|0
Set 3D Stereo Enhancement to 1 (on) or 0 (off)
-agc, --agc 1|0
Set Automatic Gain Control for microphone to 1 (on) or 0 (off)
-get restore the saved values from $HOME/.camrc
-save save the values to $HOME/.camrc
-getfile filename
restore the saved values from file 'filename'
-savefile filename
save the values to file 'filename'
-h, -?, --help
displays help
NOTE: x and y are in range from 1 to 100. Higher or lower numbers are
ignored.
BUGS
None known as yet. If you find one, please let me know.
AUTHOR
Jan 'TWP' VANDENBERGHE <jvdbergh@uia.ua.ac.be>
cam(1)