06-24-2008
use a case statement
severity=`awk '/\[Alarm Severity\]:/ {print $3}' file`
case $severity in
MINOR) <statements> ;;
MAJOR) <statements> ;;
...
...
esac
not sure if this is the best way...
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
I am fairly new in unix I was wondering if anybody can help me out with this:
I am trying to output to a file the following fields;
Field1
Field2
Field4
From a database file dataBase1.
this is how the file looks:
dataBase1 TABLE DATA Example
==================
Table ... (3 Replies)
Discussion started by: Dennz
3 Replies
2. Shell Programming and Scripting
Hi Everyone,
# cat a.txt
94,aqqc,62345907,
5,aeec,77,
# cat 1.pl
#!/usr/bin/perl
use strict;
use warnings;
use Date::Manip;
open(my $FA, "/root/a.txt") or die "$!";
while(<$FA>) {
chomp;
my @tmp=split(/\,/, $_);
if (index($tmp, "qq") ne -1) {
... (4 Replies)
Discussion started by: jimmy_y
4 Replies
3. Shell Programming and Scripting
Hi Everyone,
Below is the script, i feel there should be more simple way to do the same output, my one works, but feel not nice. like using index i feel it is slow (image my file is very large), maybe awk can do one line code?
Please advice.
# cat 1.txt
1 a
2 b
3 cc
4 d
# cat 1.pl... (6 Replies)
Discussion started by: jimmy_y
6 Replies
4. Shell Programming and Scripting
Hi,
I had input file with below data,
abcdefghij;20100903040607;1234567891;GLOBAL;
Having values of fields with seperated by semi-colon (;) and ended with line feed (\n).
Through shell script, how can I check the field formatting?
Thanks in advance. (18 Replies)
Discussion started by: Poonamol
18 Replies
5. Shell Programming and Scripting
Hello everyone,
I think this would be easy for you experts.
Refering the suggestion that Scrutinizer gave me in this thread https://www.unix.com/302612499-post13.html
I have the script in this form
awk '{$1=$1}1' "$1" | awk ' ...'
Where "$1" takes the value of "inputfile" then I can... (1 Reply)
Discussion started by: Ophiuchus
1 Replies
6. Shell Programming and Scripting
Hi Friends,
Need Help. I have file1.txt as
File1.txt
|123|A|7267|Hyder|Cross|Sell|7801
|995|A|7051|2008|Lunar|New|Year|Promotion|7801
|996|A|7022|Q108|Targ|Prospect|&|SSCC|Savings|Promo|7801
|997|A|7182|Q1|Feb-Apr|08|Credit|ITA|PA|SBA|Campaign|7801
File2.txt... (7 Replies)
Discussion started by: i150371485
7 Replies
7. Shell Programming and Scripting
Hi Freinds,
I have 2 files . one is source.txt and second one is target.txt. I want to keep source.txt as baseline and compare target.txt. please find the data in 2 files and Expected output.
Source.txt
1|HYD|NAG|TRA|34.5|1234
2|CHE|ESW|DES|36.5|134
3|BAN|MEH|TRA|33.5|234... (5 Replies)
Discussion started by: i150371485
5 Replies
8. Shell Programming and Scripting
HI,
I have one file which is as below
cat /var/tmp/test1 | awk '{ print $3}'|grep -v affected
Data
----------
200.4
. The above 200 value is changable by the database script.
Now I need a script that checks the value 200.4 and the script shoud give out put if value is more than 225 (2 Replies)
Discussion started by: phani4u
2 Replies
9. UNIX for Dummies Questions & Answers
Hi All
I have a .dat file, the values are seperated by ". I wish to identify all field values in field 14 that are not '01-APR-2013' band then copy those records to a new file. Can anyone suggest the UNIX command required.
Thanks in advance
Andy (2 Replies)
Discussion started by: aurum1313
2 Replies
10. Shell Programming and Scripting
I need a script to check the records in a file , if any value match transfer the record in error.txt file.
1- If any of the any field value is NULL(nothing in this field)
Record1|Record2|Record3|Record4|Record5|DATE1|DATE2
Example:
11111111|22222222|NULL|12|444|27042018|27042018... (8 Replies)
Discussion started by: vivekn
8 Replies
LEARN ABOUT OPENSOLARIS
addseverity
addseverity(3C) Standard C Library Functions addseverity(3C)
NAME
addseverity - build a list of severity levels for an application for use with fmtmsg
SYNOPSIS
#include <fmtmsg.h>
int addseverity(int severity, const char *string);
DESCRIPTION
The addseverity() function builds a list of severity levels for an application to be used with the message formatting facility fmtmsg().
The severity argument is an integer value indicating the seriousness of the condition. The string argument is a pointer to a string
describing the condition (string is not limited to a specific size).
If addseverity() is called with an integer value that has not been previously defined, the function adds that new severity value and print
string to the existing set of standard severity levels.
If addseverity() is called with an integer value that has been previously defined, the function redefines that value with the new print
string. Previously defined severity levels may be removed by supplying the null string. If addseverity() is called with a negative number
or an integer value of 0, 1, 2, 3, or 4, the function fails and returns -1. The values 0-4 are reserved for the standard severity levels
and cannot be modified. Identifiers for the standard levels of severity are:
MM_HALT Indicates that the application has encountered a severe fault and is halting. Produces the print string HALT.
MM_ERROR Indicates that the application has detected a fault. Produces the print string ERROR.
MM_WARNING Indicates a condition that is out of the ordinary, that might be a problem, and should be watched. Produces the print string
WARNING.
MM_INFO Provides information about a condition that is not in error. Produces the print string INFO.
MM_NOSEV Indicates that no severity level is supplied for the message.
Severity levels may also be defined at run time using the SEV_LEVEL environment variable (see fmtmsg(3C)).
RETURN VALUES
Upon successful completion, addseverity() returns MM_OK. Otherwise it returns MM_NOTOK.
EXAMPLES
Example 1 Example of addseverity() function.
When the function call
addseverity(7,"ALERT")
is followed by the call
fmtmsg(MM_PRINT, "UX:cat", 7, "invalid syntax", "refer to manual",
"UX:cat:001")
the resulting output is
UX:cat: ALERT: invalid syntax
TO FIX: refer to manual UX:cat:001
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|MT-Level |Safe |
+-----------------------------+-----------------------------+
SEE ALSO
fmtmsg(1), fmtmsg(3C), gettxt(3C), printf(3C), attributes(5)
SunOS 5.11 29 Dec 1996 addseverity(3C)