Solved

awk question

Posted on 2001-09-07
5
1,006 Views
Last Modified: 2011-09-20
perhaps its friday but i cannot see why this little devil is eluding me.  i have a log file that gives an error code in column three. we look at the file and have to type msg xxx to get the appropriate narrative. i thought i would just write a script to give me the errors and then do a msg for each one it found. this is what i started but not sure what is eluding me.  please advise.

for i in `awk {print $3} log`
  do
     msg $i
   done  

thanks,
banba

here is the error msg:
Syntax Error The source line is 1.
 The error context is
                 >>> {print <<<
 awk: 0602-502 The statement cannot be correctly parsed. The source line is 1.  


here is the sample (i am after the x,x,x errors)

2000/09/07 00:11:57.591 80,0,55 <fnsw> bes_commit (17802) ... [WARNING]
DOC: Doc migration requested on Server (id=2) which has no Storage Libraries

2000/09/07 00:12:13.272 80,0,55 <fnsw> BESs (44898) ... [WARNING]
DOC: Doc migration requested on Server (id=2) which has no Storage Libraries

2000/09/07 08:33:48.870 90,0,19 <fnsw> INXs (29930) ...
INXl_validate: error on doc_id 119925                        
0
Comment
Question by:banba
  • 4
5 Comments
 
LVL 6

Expert Comment

by:bira
ID: 6465555
Hi

  May you post piece of your log file, and
  the result yor are getting
0
 
LVL 6

Expert Comment

by:bira
ID: 6465566
Or try

 for i in `cat log | awk {print $3)`
 do
    msg $i
  done  
0
 
LVL 6

Expert Comment

by:bira
ID: 6465603
Or

 for i in `cat log | awk {'print $3')`
do
   msg $i
 done  
0
 
LVL 6

Accepted Solution

by:
bira earned 100 total points
ID: 6465686
Dear banba

  Now it is tested ok and works fine. forget the previous,
 because they have some syntax problem.
 


for i in `awk '{print $3}' log`
do
msg $i
done


   Regards
0
 

Author Comment

by:banba
ID: 6470796
thanks so much, as i drove home bleary eyed on friday, i wondered if it was due to an errant tic mark. it works just fine!

best regards,
banba
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now