Sponsored Content
Top Forums Shell Programming and Scripting Regular expression query in AWK Post 302088893 by Ygor on Friday 15th of September 2006 03:09:47 AM
Old 09-15-2006
Try...
Code:
awk 'BEGIN{
      var = "[timestamp] [priority] - [log message]"
      n = split(var, arr, /(^\[)|(\] -? ?\[)|(\]$)/)
      for (x=2; x<n; x++)
          printf "arr[%d]=%s\n", x, arr[x]
     }'

...result is...
Code:
arr[2]=timestamp
arr[3]=priority
arr[4]=log message

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk and regular expression

Ive got a file with words and also numbers. Bla BLA 10 10 11 29 12 89 13 35 And i need to change "10,29,89,25" and also remove anything that contains actually words... (4 Replies)
Discussion started by: maskot
4 Replies

2. UNIX for Dummies Questions & Answers

regular expression and awk

I can print a line with an expression using this: awk '/regex/' I can print the line immediately before an expression using this: awk '/regex/{print x};{x=$0}' How do I print the line immediately before and then the line with the expression? (2 Replies)
Discussion started by: nickg
2 Replies

3. Shell Programming and Scripting

need help guys for Regular expression in awk

Hello Experts, Please help me to cope with the following problem I ve patterens like Input Noptx(5) // remain the same -*Nop(3); Nop(9); --Nop(8); // remain the same d3 **---Nop(7); //remain the same d3 **---Nop(7); *--Nop(6); --**Nop(5); -Nop(4); Nop(3); - represents a space... (2 Replies)
Discussion started by: user_prady
2 Replies

4. Shell Programming and Scripting

Regular expression query in AWK

Hi, I have a string like this-->"After Executing service For 10 Request" in this string i need to extract "10". the contents of the string is variable and "10" appears before "For" and after "Request" i.e, in this format "For x Request" I need to extract the value of x. How to do this in AWK?... (10 Replies)
Discussion started by: omprasad
10 Replies

5. Shell Programming and Scripting

Awk's variable in regular expression

Anyone know how I will use awk's variable in a regular expression? This line of code of mine is working, the value PREMS should be a variable: awk '$1 ~ /PREMS/ { if(length(appldata)+2 >= length($1)) print $0; }' appldata=$APPLDATA /tmp/file.tmp The value of APPLDATA variable is PREMS. ... (2 Replies)
Discussion started by: Orbix
2 Replies

6. Shell Programming and Scripting

Query Regarding Regular Expression

Can you please tell me the meaning of .* For eg. i have a text as "Scrapple the apple" Now here, what does a.*e will match? (7 Replies)
Discussion started by: Shell_Learner
7 Replies

7. Shell Programming and Scripting

Regular expression in AWK

Hello world, I was wondering if there is a nicer way to write the following code (in AWK): awk ' FNR==NR&&$1~/^m$/{tok1=1} FNR==NR&&$1~/^m10$/{tok1=1} ' my_file In fact, it looks for m2, m4, m6, m8 and m10 and then return a positive flag. The problem is how to define 10 thanks... (3 Replies)
Discussion started by: jolecanard
3 Replies

8. Programming

Perl: How to read from a file, do regular expression and then replace the found regular expression

Hi all, How am I read a file, find the match regular expression and overwrite to the same files. open DESTINATION_FILE, "<tmptravl.dat" or die "tmptravl.dat"; open NEW_DESTINATION_FILE, ">new_tmptravl.dat" or die "new_tmptravl.dat"; while (<DESTINATION_FILE>) { # print... (1 Reply)
Discussion started by: jessy83
1 Replies

9. Shell Programming and Scripting

awk regular expression

Hello, I have big files which I wanna filter them based on first column. first column should be one of these strings: chr2L || chr2R || chr3L || chr3R || chr4 || chrX and something like chr2Lh or chrY or chrM3L is not accepted. I used the following command: awk '{ if ($1=="chr2L" ||... (5 Replies)
Discussion started by: @man
5 Replies

10. Shell Programming and Scripting

awk regular expression search

Hi All, I would like to search a regular expression by passing as an i/p variableto AWK. For Example :: 162.111.101.209.9516 162.111.101.209.41891 162.111.101.209.9516 162.111.101.209.9517 162.111.101.209.41918 162.111.101.209.9517 162.111.101.209.41937 162.111.101.209.41951... (7 Replies)
Discussion started by: Girish19
7 Replies
strerr(1M)						  System Administration Commands						strerr(1M)

NAME
strerr - STREAMS error logger daemon SYNOPSIS
strerr DESCRIPTION
strerr receives error log messages from the STREAMS log driver (see log(7D)) and appends them to a log file. The resultant error log files reside in the directory /var/adm/streams, and are named error.mm-dd, where mm is the month and dd is the day of the messages contained in each log file. The format of an error log message is: <seq> <time> <ticks> <flags> <mid> <sid> <text> <seq> error sequence number <time> time of message in hh:mm:ss <ticks> time of message in machine ticks since boot priority level <flags> T : the message was also sent to a tracing process F : indicates a fatal error N : send mail to the system administrator (hardcoded as root) <mid> module ID number of source <sid> sub-ID number of source <text> formatted text of the error message Messages that appear in the error log are intended to report exceptional conditions that require the attention of the system administrator. Those messages which indicate the total failure of a STREAMS driver or module should have the F flag set. Those messages requiring the immediate attention of the administrator will have the N flag set, which causes the error logger to send the message to the system adminis- trator using mail. The priority level usually has no meaning in the error log but will have meaning if the message is also sent to a tracer process. Once initiated, strerr continues to execute until terminated by the user. It is commonly executed asynchronously. FILES
/var/adm/streams/error.mm-dd error log file. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
attributes(5), log(7D) STREAMS Programming Guide NOTES
There is no restriction to the number of strerr processes opening the STREAMS log driver at a time. If a module or driver is generating a large number of error messages, running the error logger will cause a degradation in STREAMS perfor- mance. If a large burst of messages are generated in a short time, the log driver may not be able to deliver some of the messages. This situation is indicated by gaps in the sequence numbering of the messages in the log files. SunOS 5.10 4 Oct 1994 strerr(1M)
All times are GMT -4. The time now is 12:32 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy