02-11-2007
The easiest way that I can think of is to use sed(1) rather than a shell if statement. It's quite simple. Your output is saved in file but can also be piped into the sed command.
# cat file | sed -e "s/^\([0-9][0-9]*\) 4 /\1 Major /" -e "s/^\([0-9][0-9]*\) 5 /\1 Critical /"
9041 Major 9041 NTX0322R_IDBEACHBRD
32555 Critical 32555 NOK3410R_IZNEMIAMI
64586 Major 64586 PTX389PR_IVSEBRNVIL
1176 Major 1176 NTX1401R_IHCENTERFI
470 Major 470 NTX0182R_IDOOOI35_U
62737 Major 62737 PTX324PR_ICN_ALICE
63715 Major 63715 PTX569PR_IWATLANTA
65711 Critical 65711 PTX123PR_IBSLUMBERT
69746 Major 69746 NTX1822R_IHKATYHAWK
28013 Major 28013 NTX1407R_IHFONVILLA
448 Major 448 NTX0130R_IDGARLAND
To add additional value translations, just and another "-e script" option. The syntax is
-e 's/^\([0-9][0-9]*\) number /\1 string /"
which says, on a line starting with one or more digits, then a space, another number, and one more space, substitute with the original starting digits, a space, a new string and a space.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
i want to sum all nubers in one column. Example:
12.23
11
23.01
3544.01
I'm trying to do this in awk, but it doesn't work properly.
Seems like awk is summing only integers, for example:
12
11
23
3544
It cuts off numbers after dot.
I used this command:
akw /text/ file.txt |nawk... (1 Reply)
Discussion started by: iahveh
1 Replies
2. UNIX for Advanced & Expert Users
Hello, I have a file, and one column has both positive and negative numbers. Does anyone know how I can calculate the total of all the values (i.e, +ve and -ve).
eg:
col1 col2 col3
data 23 data
data 76 data
data -30 data
Thanks
Khoom (1 Reply)
Discussion started by: Khoomfire
1 Replies
3. Shell Programming and Scripting
Hi All thanks a lot for your previous replies. I need some help here. I am writing a script to test a machine for a thereshold. It is genrating the list of number that have to be added but not displaying the added value.
The script is like this
#!/bin/sh... (1 Reply)
Discussion started by: asirohi
1 Replies
4. Shell Programming and Scripting
Hello all
siteexplorer.search.yahoo.com can output results in tsv format, when opened in excel I get 4 columns.
I would like to wget that file, which I can do. I would then like to pull the 2nd column and output it only.
I've searched around and found a few bits and pieces but nothing I've... (6 Replies)
Discussion started by: casphar
6 Replies
5. UNIX for Dummies Questions & Answers
I have UWIn version of Unix for Desktop.
I have a file (Subtitle file of a movie) with the following format
abc def ghi jkl
mno pqr stuv
uvw xyz
The subtitles are delayed about a min or few seconds more. I want to increase it to be as shown below:
abc def ghi jkl
mno pqr stuv
... (4 Replies)
Discussion started by: bobbygsk
4 Replies
6. Shell Programming and Scripting
Howdy experts,
We have some ranges of number which belongs to particual group as below.
GroupNo StartRange EndRange
Group0125 935300 935399
Group2006 935400 935476
937430 937459
Group0324 935477 935549
... (6 Replies)
Discussion started by: thepurple
6 Replies
7. Shell Programming and Scripting
Hi,
I have a system under test, and I use a script that does a ps.
The output, is in the following format, it's basically the timestamp, followed by the rss and vsize.
09:03:57 68404 183656 68312 181944 69860 217360 67536 182564 69072 183172 69032 199276
09:04:27 68752 183292 70000 189020... (5 Replies)
Discussion started by: Bloke
5 Replies
8. Shell Programming and Scripting
Problem discription:
I have many files which contain the same lines.
for instance, (15 lines) file1 ..last column add by hand arbitrarily.
1.78116800 0.68396600 0.00061900
0.47641600 -0.49794500 -0.00024000
-1.70662800 0.29577100 0.67863600
-1.70647600 0.29654600 ... (9 Replies)
Discussion started by: liuzhencc
9 Replies
9. Shell Programming and Scripting
Given a file test.txt ,I can get a list of numbers in a single column using the command :
cat test.txt | cut -d ' ' -f 8 that gives the output as
52
52
52
60
52
How can I get the sum of all the numbers in that column that is displayed?
i want the output as
sum=268 (4 Replies)
Discussion started by: hitha87
4 Replies
10. UNIX for Dummies Questions & Answers
Hello. Trying to add a column of numbers and combine the 1st and 2nd fields as uniq with the new total.
This works to add the numbers but can't figure an easy was to combine the 1st and 2nd column as the list is very long. awk '{s+=$3} END {print s}'
bird dog 300
bird dog 100
cat clown 200... (1 Reply)
Discussion started by: jimmyf
1 Replies
COLRM(1) BSD General Commands Manual COLRM(1)
NAME
colrm -- remove columns from a file
SYNOPSIS
colrm [start [stop]]
DESCRIPTION
The colrm utility removes selected columns from the lines of a file. A column is defined as a single character in a line. Input is read
from the standard input. Output is written to the standard output.
If only the start column is specified, columns numbered less than the start column will be written. If both start and stop columns are spec-
ified, columns numbered less than the start column or greater than the stop column will be written. Column numbering starts with one, not
zero.
Tab characters increment the column count to the next multiple of eight. Backspace characters decrement the column count by one.
ENVIRONMENT
The LANG, LC_ALL and LC_CTYPE environment variables affect the execution of colrm as described in environ(7).
EXIT STATUS
The colrm utility exits 0 on success, and >0 if an error occurs.
SEE ALSO
awk(1), column(1), cut(1), paste(1)
HISTORY
The colrm command appeared in 3.0BSD.
BSD
August 4, 2004 BSD