Sponsored Content
Operating Systems Solaris grep and display few lines before and after Post 302101668 by Tornado on Wednesday 3rd of January 2007 07:02:49 PM
Old 01-03-2007
Here's an example of how I have used wgrep on one of our Sunfire v440 servers
Code:
[tst1/] uname -a
SunOS tst1 5.9 Generic_112233-10 sun4u sparc SUNW,Sun-Fire-V440
[tst1/] prtpicl -v -c temperature-sensor | wgrep -w0:6 HighPowerOffThreshold | grep -v Low
********** STDIN **********
  :HighPowerOffThreshold         120 
  :HighShutdownThreshold         102 
  :HighWarningThreshold  97 
  :Temperature   43 
**********
  :HighPowerOffThreshold         120 
  :HighShutdownThreshold         102 
  :HighWarningThreshold  97 
  :Temperature   45 
**********
  :HighPowerOffThreshold         75 
  :HighShutdownThreshold         65 
  :HighWarningThreshold  60 
  :Temperature   25 
**********
  :HighPowerOffThreshold         75 
  :HighShutdownThreshold         65 
  :HighWarningThreshold  60 
  :Temperature   25 
**********
  :HighPowerOffThreshold         62 
  :HighShutdownThreshold         52 
  :HighWarningThreshold  47 
  :Temperature   21 
**********
  :HighPowerOffThreshold         85 
  :HighShutdownThreshold         75 
  :HighWarningThreshold  65 
  :Temperature   27 
[tst1/]

Tornado
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Make grep -c display like grep -n?

Hey Guys, Wondering if there is a way to do the following I have a file called test.txt abc def abc abc def I have a pattern file called pattern.txt containing the following abc def I want to do a count, but have it display the count value preceeding each line like grep -n (2 Replies)
Discussion started by: Jerrad
2 Replies

2. UNIX for Dummies Questions & Answers

Help with "grep", need to display several lines

I have a file from which I need to collect lines to another file. I know how to use 'grep' for this, but I don't know how to do when I wan't several lines after the search word, and the amount of lines I need varies from case to case. The file I search in looks something like this: >8534734... (9 Replies)
Discussion started by: Draken
9 Replies

3. UNIX for Dummies Questions & Answers

Grep and display n lines after the match is found.

Hello, How do I use grep to find a pattern in a list of file and then display 5 lines after the pattern is matched Eg: I want to match the string GetPresentCode in all files in a folder and then see 4 lines following this match. I am not sure if grep is what should be used to achieve. Thanks!... (3 Replies)
Discussion started by: cv_pan
3 Replies

4. Shell Programming and Scripting

grep and display lines from a file

I have to grep on a few words in a file and then display the line containing those words and the line above it. For ex - File1.txt contains... abc xyz abc This is a test Test successful abc xyz abc Just a test Test successful I find the words 'Test successful' in the file... (6 Replies)
Discussion started by: user7617
6 Replies

5. UNIX for Dummies Questions & Answers

Using grep and zgrep then display the next few lines

Hello everyone. I would like to know if I can use grep or zgrep to search for a particular pattern then print the x number of lines after the pattern was found. Lets say for example a pattern was found on line 3, I wanted the output to show lines 3, 4 and 5. Thanks! (10 Replies)
Discussion started by: khestoi
10 Replies

6. Shell Programming and Scripting

Grep word after last occurance of string and display next few lines

Hi, I wanted to grep string "ERROR" and "WORNING" after last occurrence of String "Starting" only and wanted to display two lines after searched ERROR and WORNING string and one line before. I have following cronjob log file "errorlog" file and I have written the code for same in Unix as below... (17 Replies)
Discussion started by: nes
17 Replies

7. Shell Programming and Scripting

Grep multiple exact match, do not display lines

Hi, Need help to grep the following from a file x. I just want to grep exact match not lines and not partial word. CONFSUCCESS CONFFAIL CONFPARTIALSUCCESS >cat x xczxczxczc zczczcxx CONFSUCCESS czczczcczc czxxczxzxczcczc CONFFAIL xczxczcxcczczc zczczczcz CONFPARTIALSUCCESS czczxcxzc ... (4 Replies)
Discussion started by: rajeshwebspere
4 Replies

8. Shell Programming and Scripting

Grep pattern and display all lines below

Hi I need to grep for a patter and display all lines below the pattern. For ex: say my file has the below lines file1 file2 file3 file4 file5 I NEED to grep for patter file3 and display all lines below the pattern. do we have an option to get this data. Let me know if you require... (5 Replies)
Discussion started by: venkidhadha
5 Replies

9. Shell Programming and Scripting

Grep and display multiple lines

Hi guys, I have a log file that generates multiple logs about a query. <query time='2016-04-13 13:01:50.825'> <PagingRequestHandler> <Before>brand:vmu</Before> <After>brand:vmu</After> </PagingRequestHandler> <GroupDeviceFilterHandler> <Before>brand:vmu</Before> ... (3 Replies)
Discussion started by: Junaid Subhani
3 Replies

10. Shell Programming and Scripting

Display lines for a particular year in a file using grep

hi, I have a log file with data for more than 3 years, i want only the rows for the year 2017, say for example. My file has the data like this 08-OCT-2015 11:17:35 AAA, BBBB 08-OCT-2017 11:17:35 AAA,Bdfdfd,dfdfd,dfd 08-Nov-2017 11:17:35 AAA,Bdfdfd,dfdfd,deree i want the rows... (2 Replies)
Discussion started by: skoshekay
2 Replies
ENVSYS.CONF(5)						      BSD File Formats Manual						    ENVSYS.CONF(5)

NAME
envsys.conf -- configuration file for the envsys(4) framework SYNOPSIS
envstat [-S] [-c /etc/envsys.conf] DESCRIPTION
The envsys.conf file configures all the features provided by the envsys(4) framework. It consists of a series of device and sensor blocks. Each sensor block defines a group of properties. The file format is free-form: new line markers and indentation are ignored. Comments start with a '#' sign and extend until the end of line. A property is like a variable assignment. It has a name, which goes to the left of the equal sign, and a value, which goes to the right. The assignment ends with a semicolon. It looks like: name = value; There is no difference between string or integer values when defining them. The value must be surrounded by double quotes if it contains whitespace. There can be multiple groups of devices and multiple groups of sensors in the configuration file. A device block consists of one or more sensor blocks and one or more global properties. It has the following syntax: device_name { prop = value; ... sensor0 { prop = value; ... } ... sensorN { prop = value; ... } } ... Device names are those shown by the 'envstat -D' command; sensor blocks are named by the index position in which they are shown. For example, if we have the following output from the envstat(8) command: CPU Temperature: 32.000 degC MB Temperature: 37.000 degC Vcore Voltage: 1.232 V +3.3 Voltage: 3.248 V +5 Voltage: 4.992 V +12 Voltage: 11.985 V CPU FAN Speed: 1250 RPM 'sensor0' corresponds to the CPU Temperature sensor and 'sensor6' corresponds to the CPU FAN Speed sensor. There is another way that will give you the correct index sensor; the 'envstat -x' command will print the raw XML property list. You only have to find the index object in the appropriate dictionary. The object will be shown as: <key>index</key> <string>sensor2</string> Invalid sensors and devices will be detected by the envstat(8) parser and will be reported as errors. The following properties are provided for sensor blocks (please note that not all properties apply to all type of sensors): critical-capacity = 10; Sets a critical capacity limit property of 10 percent in a battery sensor. Battery sensors are those that report a percentage from the envstat(8) output. It is possible to find out if the sensor accepts this property by running 'envstat -x' and looking if the want-percentage object is defined as true on its dictionary. For example: <key>want-percentage</key> <true/> Only a value between 0 and 100 is allowed. When the limit is reached in the sensor, a critical-capacity event will be sent to the powerd(8) daemon (if running) and will execute the block for this event in /etc/powerd/scripts/sensor_battery. If this property is set, its value will be shown in the envstat(8) display output with a column named CritMin. warning-capacity = 20; Sets a warning capacity limit property of 20 percent in a battery sensor. Battery sensors are those that report a percentage from the envstat(8) output. It is possible to find out if the sensor accepts this property by running 'envstat -x' and looking if the want-percentage object is defined as true on its dictionary. For example: <key>want-percentage</key> <true/> Only a value between 0 and 100 is allowed. When the limit is reached in the sensor, a warning-capacity event will be sent to the powerd(8) daemon (if running) and will execute the block for this event in /etc/powerd/scripts/sensor_battery. If this property is set, its value will be shown in the envstat(8) display output with a column named WarnMin. high-capacity = 90; Sets a high capacity limit property of 90 percent in a battery sensor. Battery sensors are those that report a percentage from the envstat(8) output. It is possible to find out if the sensor accepts this property by running 'envstat -x' and looking if the want-percentage object is defined as true on its dictionary. For example: <key>want-percentage</key> <true/> Only a value between 0 and 100 is allowed. When the limit is reached in the sensor, a high-capacity event will be sent to the powerd(8) daemon (if running) and will execute the block for this event in /etc/powerd/scripts/sensor_battery. If this property is set, its value will be shown in the envstat(8) display output with a column named WarnMax. maximum-capacity = 99; Sets a warning capacity limit property of 99 percent in a battery sensor. Battery sensors are those that report a percentage from the envstat(8) output. It is possible to find out if the sensor accepts this property by running 'envstat -x' and looking if the want-percentage object is defined as true on its dictionary. For example: <key>want-percentage</key> <true/> Only a value between 0 and 100 is allowed. When the limit is reached in the sensor, a warning-capacity event will be sent to the powerd(8) daemon (if running) and will execute the block for this event in /etc/powerd/scripts/sensor_battery. If this property is set, its value will be shown in the envstat(8) display output with a column named WarnMin. critical-max = 70C; Sets a critical maximum limit property in a sensor. Note that in this example, we are specifying the 'C' keyword at the end; that means that this will only be valid for temperature sensors and that the value is specified as degrees Celsius. If degrees Fahrenheit are wanted, just use the letter F, as in: critical-max = 140F; To know sensor type, you have to look at the type object in the XML property list. Remember: the XML property list has all the infor- mation that the application uses to print the values! Other sensors that are not of temperature type must not include the final character for the unit. A dot is allowed in the value, if it corresponds to the range that the sensor is reporting. When the limit has been reached in the sensor, a critical-over event will be sent to the powerd(8) daemon (if running) and will execute the block for this event in the appropriate /etc/powerd/scripts/sensor_foo script (depending on the sensor's type). Please note that this property cannot be set in battery capacity sensors (those that have the want-percentage object in their dictio- nary). This rule applies for the 'critical-min', 'warning-max', and 'warning-min' properties too. If this property is set, its value will be shown in the envstat(8) display output with a column named CritMax. critical-min = 1.230; Sets a critical minimum limit property in a sensor. The rules for critical-max, critical-min, warning-max, and warning-min are the same. When the limit has been reached in the sensor, a critical-under event will be sent to the powerd(8) daemon (if running) and will execute the block for this event in the appropriate /etc/powerd/scripts/sensor_foo script (depending on the sensor's type). If this property is set, its value will be shown in the envstat(8) display output with a column named CritMin. warning-max = 70C; Sets a warning maximum limit property in a sensor. The rules for critical-max, critical-min, warning-max, and warning-min are the same. When the limit has been reached in the sensor, a warning-over event will be sent to the powerd(8) daemon (if running) and will execute the block for this event in the appropriate /etc/powerd/scripts/sensor_foo script (depending on the sensor's type). Please note that this property cannot be set in battery capacity sensors (those that have the want-percentage object in their dictio- nary). This rule applies for the 'warning-min' property too. If this property is set, its value will be shown in the envstat(8) display output with a column named WarnMax. warning-min = 1.230; Sets a critical minimum limit property in a sensor. The rules for critical-max, critical-min, warning-max, and warning-min are the same. When the limit has been reached in the sensor, a warning-under event will be sent to the powerd(8) daemon (if running) and will execute the block for this event in the appropriate /etc/powerd/scripts/sensor_foo script (depending on the sensor's type). If this property is set, its value will be shown in the envstat(8) display output with a column named WarnMin. description = string Sets a new description in a sensor. You can set this property in all sensors, except that you won't be able to set a description that is currently used for the specified device. rfact = 56000 Sets a new resistor factor property in a sensor. This property is only allowed in Voltage sensors and only if the device has enabled the appropriate flag for the mentioned sensor. The resistor factor may be used to change the behavior of the value returned by the device. If a sensor supports this, the allow-rfact object appears enabled (true) in the dictionary. The following properties are available for device blocks: refresh-timeout = 10s This property sets the refresh timeout value in a device, and will be used to refresh data and check for critical conditions any time the timeout is met. The value may be specified in seconds, minutes or hours. To specify the value in seconds, the s character must be appended last, if minutes is desired, a m and a h for hours. For example 10s for 10 seconds or 1h for one hour. FILES
/etc/envsys.conf Default configuration file. SEE ALSO
proplib(3), envsys(4), envstat(8), powerd(8) HISTORY
The envsys.conf configuration file first appeared in NetBSD 5.0. BSD
February 15, 2010 BSD
All times are GMT -4. The time now is 02:24 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy