Sponsored Content
Homework and Emergencies Emergency UNIX and Linux Support Complicated SED search required Post 302371443 by badoshi on Saturday 14th of November 2009 08:13:16 PM
Old 11-14-2009
Complicated SED search required

Hi All,

I'm trying to extract all the description fields from a MIB file which contain multiple instances of the following text:

Code:
        ENTERPRISE compaq
        VARIABLES  { sysName, cpqHoTrapFlags, cpqSsBoxCntlrHwLocation,
                     cpqSsBoxCntlrIndex, cpqSsBoxBusIndex, cpqSsBoxVendor,
                     cpqSsBoxModel, cpqSsBoxSerialNumber, cpqSsBoxFanStatus }
        DESCRIPTION
           "Storage System fan status change.

            The agent has detected a change in the Fan Status of a storage
            system.  The variable cpqSsBoxFanStatus indicates the current
            fan status.

            User Action: If the fan status is degraded or failed, replace
            any failed fans."

              --#TYPE "Fan Status Change (8026)"

Ideally I need to search through the document, and for each instance of 'DESCRIPTION' found, I need to extract the text found immediately after it in quotes, and join them onto a single line. So for example the above would produce something like:

Code:
Storage System fan status change. The agent has detected a change in the Fan Status of a storage system.  The variable cpqSsBoxFanStatus indicates the current fan status. User Action: If the fan status is degraded or failed, replace any failed fans.

Each instance should be on a seperate line. I'm getting nowhere with this, as my grasp of sed/awk is basic to say the least.

If someone could help me out here, it would literally save me hours or even days in monotonous work!

tia.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help in sed required.

Hi All, I am facing a small problem in sed. I want to insert a line in the existing file. Existing code: access to attr=userPassword by self write by * auth access to * by self write by users read by anonymous auth Desired code: access to attr=userPassword by self... (14 Replies)
Discussion started by: nua7
14 Replies

2. Shell Programming and Scripting

complicated search within file

Hi, I have following problem. I have a file with time stamps and some data describing what happened between time stamps. Something like this: 10:00 meeting with K meeting with L 11:00 lunch 12:00 work with K 13:00 From this file I have to get a file with... (7 Replies)
Discussion started by: mmike
7 Replies

3. Shell Programming and Scripting

Script Search replace - complicated

I have a text file for which i need a script which does some fancy search and replace. Basically i want to loop through each line, if i find an occurance of certain string format then i want to carry on search on replace another line, once i replaced this line i will contine to search for the... (7 Replies)
Discussion started by: kelseyh
7 Replies

4. Shell Programming and Scripting

Search complicated strings on file

Can someone help me? I been figuring out how I can search and extract a complicated search string from a file. The whole string is delimited by a period. And the file where I'm searching is composed of differnt string such as that. For example, I have this search string: and I have a file... (3 Replies)
Discussion started by: Orbix
3 Replies

5. Shell Programming and Scripting

Parsing complicated CSV file with sed

Yes, there is a great doc out there that discusses parsing csv files with sed, and this topic has been covered before but not enough to answer my question (unix.com forums). I'm trying to parse a CSV file that has optional quotes like the following: "Apple","Apples, are fun",3.60,4.4,"I... (3 Replies)
Discussion started by: analog999
3 Replies

6. Shell Programming and Scripting

sed help required

Hi All, I have one file with below type of data in it, $ cat test.txt ###123 ###xyxytuerwb ###2 ###tyupe Here I would like to replace all the characters with "x" after the 3 "###" with the same number of characters. Can you please help me to achieve this. (7 Replies)
Discussion started by: gr8_usk
7 Replies

7. Shell Programming and Scripting

sed with complicated variable pattern

Hi, Below is the content of the file how it looks: # EMAIL #export BMS_EMAIL_ENABLED=true export BMS_EMAIL_ENABLED=false #export BMS_EMAIL_SERVER=esasmtp01.kohls.com export BMS_EMAIL_SERVER=esasmtp01.kohls.com.SMTP_SERVICE export BMS_EMAIL_FROM_ADDRESS=ec_notify@kohlsectest.com export... (4 Replies)
Discussion started by: pravintse
4 Replies

8. Shell Programming and Scripting

sed help - search/copy from one file and search/paste to another

I am a newbie and would like some help with the following - Trying to search fileA for a string similar to - AS11000022010 30.4 31.7 43.7 53.8 60.5 71.1 75.2 74.7 66.9 56.6 42.7 32.5 53.3 I then want to replace that string with a string from fileB - ... (5 Replies)
Discussion started by: ncwxpanther
5 Replies

9. UNIX for Beginners Questions & Answers

How to search a text in file and retrieve required lines following it with UNIX command?

I have requirement to search for a text in the file and retrieve required lines that is user defined with unix command. Eg: Find the text UNIX in the below file and need to return Test 8 & Test 9 Test 1 Test 2 Test 3 Test 4 UNIX Test 5 Test 6 Test 7 Test 8 Test 9 Result can... (8 Replies)
Discussion started by: Arunkumarsak4
8 Replies

10. UNIX for Beginners Questions & Answers

Assistance required to decode sed search using /1

Hi, I am trying to extract line number (first number), as well as everything from TSVal onwards. 4 1.474005 172.18.124.142 -> 74.125.228.46 TCP 2450940617 74 44021 > https Seq=0 Win=5840 Len=0 MSS=1380 SACK_PERM=1 TSval=2450940617 TSecr=0 WS=64 6 1.488149 172.18.124.142 ->... (1 Reply)
Discussion started by: sand1234
1 Replies
i8kmon(1)							     Utilities								 i8kmon(1)

NAME
I8kmon - Monitor the cpu temperature and fan status on Dell Inspiron laptops SYNTAX
i8kmon [<options>] DESCRIPTION
The i8kmon daemon can be used to monitor the cpu temperature and fan status on Dell Inspiron laptops. The program can be run in background as daemon or under X as an applet which can be swallowed in the gnome panel. By default the program monitors the cpu temperature but doesn't do any automatic controls of the fan status accordingly to user-defined temperature thresholds because this may not be needed if your laptop does already a good job with fans control. The automatic control can be enabled manually with the --auto option. The automatic fan control can also be turned on in the control popup menu which is invoked by clicking with the left mouse button on the temperature label. The control menu has three items: Auto, which controls the automatic fan control, Verbose, which prints status on std- out, and Suspend, which closes the /proc/i8kfan file and suspends the daemon to allow unloading the kernel module. The user interface reports the current cpu temperature in the top box and in the two lower buttons the status of the fans. On systems wiht only one fan the interface shows only one fan button. If a button's background becomes red it means that the corresponding fan has a rota- tion speed lower than the minimum expected speed and is probably stuck. In this case proding it with a bent paper clip can often cause it to become unstuck. The fan buttons can also be used to manually control the fan speeds. Clicking on a fan button with the left mouse button will cycle the selected fan between low speed, high speed and off. Clicking with the middle button will set the fan to high speed and clicking with the right button will switch the fan off. Note however that both the BIOS and the daemon have their own idea of what the fan speed should be and can sometimes try to override the manual settings. OPTIONS
The program accepts the following command-line options: -a, --auto Monitor cpu temperature and fan status and control automatically the fans. -na, --noauto Monitor cpu temperature and fan status but don't control automatically the fans. This is the default setting. -d, --daemon Run the program in daemon mode, i.e. without the user interface. -nd, --nodaemon Don't run the program in daemon mode, i.e. open the user interface. This is the default setting. -nc, --nouserconfig Don't attempt to source the ~/.i8kmon configfile, only /etc/i8kmon. -v, --verbose Report hardware status and program actions on stdout. -g, --geometry <geometry> Specifies the geometry of the applet window. Geometry should be 24x24, 36x36 or 48x48 to fit the size of the gnome panel. -t, --timeout <seconds> Specifies the interval at which the daemon checks the hardware status. Useful values are in the range of 1-5 seconds. Default is 2 seconds. -u, --unit C|F Specifies the temperature display unit. Default is C (Celsius). This option affects only the value shown in the applet. All other temperature values are always in Celsius. CONFIGURATION
The program has builtin defaults and temperature thresholds but users can specify their own settings in configuration files /etc/default/i8kmon and ~/.i8kmon. The daemon defines 4 states with different fan speeds ({0 0}, {1 0}, {1 1}, {2 2}) and for each state are defined the temperature thresholds which cause the switching to a higher or lower state. Furthermore each state can have different thresholds for operation on ac power or battery. For example the following configuration: set config(0) {{0 0} -1 60 -1 65} set config(1) {{1 0} 50 70 55 75} set config(2) {{1 1} 60 80 65 85} set config(3) {{2 2} 70 128 75 128} defines state 0 with both fans off, high threshold of 60 degrees (65 on battery) and low threshold -1, which is actually never reached since 0 is the lowest state. When the high threshold is reached the program switches to state 1 (left low, right off) which has a high threshold of 70 degrees and a low threshold of 50 degrees. If the temperature drops below 50 the program will switch back to state 0, if it rises above 70 it will enter state 2, and so on. For better operation the temperature ranges should be overlapping with an hysteresis of at least 10 degrees, i.e. 1={50 70},2={60 80} is better than 1={50 70},2={70 80}. It must be rembered that the low threshold of state 0 must be -1 and the high threshold of state 3 must be 128. If your laptop has only one fan you should specify a '-' instead of the fan speed of the missing fan, for example: set config(2) {{1 -} 60 80 65 85} This program can be used by normal users as Gnome panel applet or started as daemon by an init script. Under Debian GNU/Linux it is possi- ble to start the daemon automatically by creating an /etc/default/i8kmon configfile containing the line "set config(daemon) 1". Note the the /etc/default/i8kmon configfile is not installed by the i8kutils package because the program is designed to be run by normal users. If you want to use it as daemon you must create the config file yourself. In this case, the --nouserconfig option can sometimes also help by limiting it to sourcing /etc/i8kmon (and not ~/.i8kmon). FILES
/proc/i8k /etc/default/i8kmon /$HOME/.i8kmon AUTHORS
Massimo Dal Zotto <dz@debian.org> COPYRIGHT
i8kmon and all the i8kutils programs , scripts and other files are distributed under the GNU General Public License (GPL). On Debian GNU/Linux systems, the complete text of the GNU General Public License can be found in `/usr/share/common-licenses/GPL'. BUGS
On some Linux distributions i8kmon exits with an error like this: can't find package Tk while executing "package require Tk" This is not a bug of i8kmon. It means that Tcl/Tk files are not installed correctly on your system and the Tk library can't be dynamically loaded from Tcl as it should be. In this case you can run i8kmon with the command: wish /usr/bin/i8kmon -- [options...] SEE ALSO
i8kctl(1), i8kbuttons(1) Massimo Dal Zotto 17 June 2005 i8kmon(1)
All times are GMT -4. The time now is 02:48 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy