Read on the numeric value in the log


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Read on the numeric value in the log
# 1  
Old 07-14-2009
Read on the numeric value in the log

For the life of me I can not seem to figure out how to read the numeric value that is listed in my log file called ncoms_connection_guard_value.log.

Here is what the format looks like in the log....
Code:
 COUNT( * )
 -----------
          48

(1 row affected)

I just want to read the value in there which is current 48 but could be any number anytime.

I tried this....
Code:
more ncoms_connection_guard_value.log | awk '{print $1}'

However this was the result....
Code:
COUNT(
-----------
48

(1

Could somebody point me in the right direction to only read the numeric value and not the rest?

Thank you in advance.

---------- Post updated at 08:40 AM ---------- Previous update was at 08:31 AM ----------

So close I can taste it!

Code:
more ncoms_connection_guard_value.log | cut -d '' -f 2-7

Results....
Code:


         48

The question now is how to I strip the line spaces out?

---------- Post updated at 08:43 AM ---------- Previous update was at 08:40 AM ----------

Got it. This is all I had to do....
Code:
more ncoms_connection_guard_value.log | cut -d '' -f 2-7 | awk '{print $1}'

Thanks!
# 2  
Old 07-14-2009
Code:
awk ' FNR==3 {print $1}' inputfilename

# 3  
Old 07-14-2009
That does not seem to return anything. And my more way is not working.
If I run this by hand it works....

Code:
#!/bin/sh
ncoms_capacity=80

/lcl/prd/apps/Tivoli/netcool/omnibus/bin/nco_sql -server NCOMS -user tivoli -password EIELAKFEFKFBFJFO < /lcl/prd/apps/Tivoli/omnibus_procedure_scripts/ncoms_connectio
n_guard.sql > /lcl/prd/apps/Tivoli/omnibus_procedure_scripts/ncoms_connection_guard_value.log

ncoms_scan=`more /lcl/prd/apps/Tivoli/omnibus_procedure_scripts/ncoms_connection_guard_value.log | cut -d '' -f 2-7 | awk '{print $1}'`
echo $ncoms_scan

Results....
Code:
bluezebra:/lcl/prd/apps/Tivoli/omnibus_procedure_scripts>./ncoms_connection_guard.sh
49

However if the system runs it say every 1 minute it does not. It catches all sorts of stuff on the screen.

For example....
Code:
ivoli/omnibus_procedure_scripts/ncoms_connection_guard_value.log 49 oli/omnibus_procedure_scripts/ncoms_connection_guard_value.log

Any ideas?

---------- Post updated at 11:55 AM ---------- Previous update was at 11:27 AM ----------

DUH!!! Not more.... Forgot about using cat. :-)

Thanks!

Last edited by LRoberts; 07-14-2009 at 04:48 PM..
# 4  
Old 07-15-2009
Code:
sed -n '/^[ ]*[0-9][0-9]*[ ]*$/{s/[ ]//g;p;}'

# 5  
Old 07-15-2009
next line after line ----
Code:
sed -n "/-----/,+1p" file | tail -1 | tr -d " "

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

How to read cron log ?

Hi everyone, I have set up a cron job and it ran as i have expected, however, i unable to determined whether it was executed by a regular user (rml5723 in this case) or by root. My intention was for it to run as root (notice the 's' bit set on the script), the script itself is owned by the... (11 Replies)
Discussion started by: rachael
11 Replies

2. Solaris

How can I read Solaris BSM log?

Hi all, I'm trying to read Solaris BSM log in user friendly form. Found old tools including bsmparser java tool and php code. But none of them working. What are you using for parsing BSM log? (2 Replies)
Discussion started by: sembii
2 Replies

3. Shell Programming and Scripting

Sort log files based on numeric value in the filename

Hi, I have a list of log files as follows: name_date_0001_ID0.log name_date_0001_ID2.log name_date_0001_ID1.log name_date_0002_ID2.log name_date_0004_ID0.log name_date_0005_ID0.log name_date_0021_ID0.log name_date_0025_ID0.log .......................................... (4 Replies)
Discussion started by: alex2005
4 Replies

4. UNIX for Advanced & Expert Users

Script to read log file

Hi, Im looking for a shell script which will search for a particular string in a log file as below scenario 1. I need to run URL http://localhost/client/update?feedid=200 in shell script at(eg)4:00 PM which will not take more than 15 mins to complete. 2. After 15 mins i need to... (6 Replies)
Discussion started by: Paulwintech
6 Replies

5. Shell Programming and Scripting

How to read log files from last read

Hi i am looking a way to look at a log file(log.txt) from the last time I've read it. However after some days the main log file(log.txt) is rename to (log.txt.1). So now i will have two log files as below. log.txt.1 log.txt Now, i have to read the log from the point where i have left... (3 Replies)
Discussion started by: sumitsks
3 Replies

6. Shell Programming and Scripting

Read from Log file in Ksh

I have a log file like.. IMPORT from /dataserver/ftp/bits/mdr/mdr_data_discon.dat OF DEL ..... Number of rows read = 1376 Number of rows skipped = 0 Number of rows inserted = 1374 Number of rows updated = 0 Number of rows rejected = 2 Number of rows... (4 Replies)
Discussion started by: ramse8pc
4 Replies

7. UNIX for Dummies Questions & Answers

Find and Replace random numeric value with non-numeric value

Can someone tell me how to change the first column in a very large 17k line file from a random 10 digit numeric value to a non numeric value. The format of lines in the file is: 1702938475,SNU022,201004 the first 10 numbers always begin with 170 (6 Replies)
Discussion started by: Bahf1s
6 Replies

8. Solaris

Read zipped log file

If we have a big zipped log file, how can we look for a specific string in this zipped log file without unzipping it? Thanks, (2 Replies)
Discussion started by: Pouchie1
2 Replies

9. Shell Programming and Scripting

How to read a specific value from a Log file?

Hi, I have a .log file in which it has many values. But i need some specific values. How it can be done using Shell Script. Please explain in detail. Thankx in advance. Sathish D V. (8 Replies)
Discussion started by: cooolthud
8 Replies

10. Shell Programming and Scripting

Perl code to differentiate numeric and non-numeric input

Hi All, Is there any code in Perl which can differentiate between numeric and non-numeric input? (11 Replies)
Discussion started by: Raynon
11 Replies
Login or Register to Ask a Question