Sub. numbers in column of output with If


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Sub. numbers in column of output with If
# 8  
Old 02-12-2007
echo "$tacg"| awk `{ ($2 == 4)? $2 = "Major": $2 = "Critical"} {print}`
~
~
~
:wq!
"acgstatus" 17 lines, 746 characters
dalsys:dalmso2 > acgstatus

Database selected.


4452 row(s) retrieved.


Database closed.


| | | |
neinstanceid | almacgcomentsever+ | neinstanceid | nename |
---------------|--------------------|-----------------|----------------|----
acgstatus[17]: syntax error at line 1 : `?' unexpected


I flipped the ' to ` and add some quotes " around tacg cause other wise it gets messy. Should I just turn it into bash. I would mind learning something new if it gets the job done fast and neat. Can you still query informix/dbacces with a bash script?
# 9  
Old 02-12-2007
Quote:
Originally Posted by ja156194
"acgstatus" 17 lines, 743 characters
dalsys:dalmso2 > acgstatus

Database selected.
# By MSO Tech II Jason C. Kelsey
db=airgen_cm_db@urban_dbhost
tacg=`echo "select a.neinstanceid, a.almacgcomentseverity, b.neinstanceid, b.nen
ame from nmo_almacgcomentry a, neentry b where a.neinstanceid=b.neinstanceid gro
up by b.neinstanceid, b.nename, a.neinstanceid, a.almacgcomentseverity" | /usr/i
nformix/bin/dbaccess $db`

echo "
| | | |
neinstanceid | almacgcomentsever+ | neinstanceid | nename |
---------------|--------------------|-----------------|----------------|----"


echo $tacg|awk '{ ($2 == 4)? $2 = "Major": $2 = "Critical"} {print}'
~
~
~
6 fewer lines in file after visual
:wq!
-----------------------------------------------------------------------

4452 row(s) retrieved.


Database closed.


| | | |
neinstanceid | almacgcomentsever+ | neinstanceid | nename |
---------------|--------------------|-----------------|----------------|----
awk: syntax error near line 1
awk: illegal statement near line 1
dalsys:dalmso2 > ^C


it is all most there, otherwise it would have spit out a bunch of junk. I see what I can do with it till I hear from you again. ;-) Thx
try nawk instead of awk

Quote:
I flipped the ' to ` and add some quotes " around tacg cause other wise it gets messy
Use quotes and not the backticks
# 10  
Old 02-12-2007
for nawk do I use the same format of text statment, just sub awk for nawk?
# 11  
Old 02-12-2007
Quote:
Originally Posted by ja156194
for nawk do I use the same format of text statment, just sub awk for nawk?
Just replace awk by nawk
# 12  
Old 02-12-2007
Computer

You save the saved the day. It wasnt an if statement but i take it. I have to find another time to brush up on if. Thanks to everyone, but if someone still has the time to place a if statement. I would love to see it also.

NAWK is da bomb!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Adding Column Of Numbers

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

2. Shell Programming and Scripting

Add up a column of numbers

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

3. Shell Programming and Scripting

How to add a column numbers at a particular position?

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

4. Shell Programming and Scripting

top output for six processes with the same name, output changed from column to row

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

5. Shell Programming and Scripting

read numbers from file and output which numbers belongs to which range

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

6. UNIX for Dummies Questions & Answers

Increasing numbers in Column

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

7. Shell Programming and Scripting

4 column tsv file, output 1 specific column

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

8. Shell Programming and Scripting

How to add numbers in a column

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

9. UNIX for Advanced & Expert Users

Adding a column of numbers

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

10. Shell Programming and Scripting

how to sum numbers in column

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
Login or Register to Ask a Question