09-15-2006
Regular expression query in AWK
I have a varable(var1) in a AWK script that contain data in the following format
[timestamp] [priority] - [log message]
I need to extract timestamp,priority and log message.I can extract these by using split function but i don't want to use it, since i want to extract it in one go. I have some difficulties in doing it using Regular expression using a single statement. Can anybody help me on this
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
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
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
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
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
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
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
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
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
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
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
LEARN ABOUT DEBIAN
log::agent::tag::priority
Agent::Tag::Priority(3pm) User Contributed Perl Documentation Agent::Tag::Priority(3pm)
NAME
Log::Agent::Tag::Priority - a log priority tag string
SYNOPSIS
Not intended to be used directly
Inherits from Log::Agent::Tag.
DESCRIPTION
This class represents a log priority tag string.
CREATION ROUTINE PARAMETERS
The following parameters are defined, in alphabetical order:
"-display" => string
Specifies the priority/level string to display, with minimal variable substitution. For instance:
-display => '[$priority/$level]'
The defined variables are documented in the DISPLAY VARIABLES section underneath.
"-level" => level
This parameter is internally added by "Log::Agent" when computing the priority tag, since only it knows the level of the current
messsage.
"-postfix" => flag
Whether tag should be placed after or before the log message. By default, it is prepended to the log message, i.e. this parameter is
false.
"-priority" => prio
This parameter is internally added by "Log::Agent" when computing the priority tag, since only it knows the priority of the current
messsage.
"-separator" => string
The separation string between the tag and the log message. A single space by default.
DISPLAY VARIABLES
The "-display" switch understands a few variables that can be substituted in the supplied string. Both $var and "${var}" forms are
supported. Unknown variables are left untouched.
$priority
The full priority name of the logged message, e.g. "warning" or "error".
$level
The associated priority level of the logged message, a number. For instance, the level associated to "warning" is 4. See
Log::Agent::Priorities for the default name -> level mapping.
AUTHOR
Raphael Manfredi <Raphael_Manfredi@pobox.com>
SEE ALSO
Log::Agent::Tag(3), Log::Agent::Message(3), Log::Agent::Priorities(3).
perl v5.10.0 2002-03-09 Agent::Tag::Priority(3pm)