Sponsored Content
Top Forums Shell Programming and Scripting Regular expression query in AWK Post 302088879 by omprasad on Friday 15th of September 2006 01:50:55 AM
Old 09-15-2006
Question 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

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
SYSLOGD(8)						    BSD System Manager's Manual 						SYSLOGD(8)

NAME
syslogd -- log systems messages SYNOPSIS
syslogd [-dnrSsTUv] [-b bind_address] [-f config_file] [-g group] [-m mark_interval] [-o output_format] [-P file_list] [-p log_socket [-p log_socket2 ...]] [-t chroot_dir] [-u user] DESCRIPTION
syslogd reads and logs messages to the system console, log files, other machines and/or users as specified by its configuration file. The options are as follows: -b bind_address Specify one specific IP address or hostname to bind to. If a hostname is specified, the IPv4 or IPv6 address which corre- sponds to it is used. -d Enable debugging to the standard output, and do not disassociate from the controlling terminal. -f config_file Specify the pathname of an alternative configuration file; the default is /etc/syslog.conf. -g group Set GID to group after the sockets and log files have been opened. -m mark_interval Select the number of minutes between ``mark'' messages; the default is 20 minutes. -n Do not perform hostname lookups; report only numeric addresses. -o output_format Select output message format. rfc3164 traditional BSD Syslog format (default) syslog new syslog-protocol format -P Specify the pathname of a file containing a list of sockets to be created. The format of the file is simply one socket per line. -p log_socket Specify the pathname of a log socket. Multiple -p options create multiple log sockets. If no -p arguments are created, the default socket of /var/run/log is used. -r Disable the compression of repeated instances of the same line into a single line of the form ``last message repeated N times''. -S Sync kernel messages to disk immediately. -s Select ``secure'' mode, in which syslogd does not listen on a UDP socket but only communicates over a UNIX domain socket. This is valuable when the machine on which syslogd runs is subject to attack over the network and it is desired that the machine be protected from attempts to remotely fill logs and similar attacks. -t chroot_dir chroot(2) to chroot_dir after the sockets and log files have been opened. -T Always use the local time and date for messages received from the network, instead of the timestamp field supplied in the message by the remote host. This is useful if some of the originating hosts can't keep time properly or are unable to gen- erate a correct timestamp. -u user Set UID to user after the sockets and log files have been opened. -U Unique priority logging. Only log messages at the priority specified by the selector in the configuration file. Without this option, messages at the specified priority or higher are logged. This option changes the default priority comparison from '>=' to '='. -v Verbose logging. If specified once, the numeric facility and priority are logged with each locally-written message. If specified more than once, the names of the facility and priority are logged with each locally-written message. syslogd reads its configuration file when it starts up and whenever it receives a hangup signal. For information on the format of the con- figuration file, see syslog.conf(5). syslogd reads messages from the UNIX domain socket /var/run/log, from an Internet domain socket specified in /etc/services, and from the spe- cial device /dev/klog (to read kernel messages). syslogd creates the file /var/run/syslogd.pid, and stores its process id there. This can be used to kill or reconfigure syslogd. By using multiple -p options, one can set up many chroot environments by passing the pathname to the log socket (/var/run/log) in each chroot area to syslogd. For example: syslogd -p /var/run/log -p /web/var/run/log -p /ftp/var/run/log Note: the normal log socket must now also be passed to syslogd. The logged message includes the date, time, and hostname (or pathname of the log socket). Commonly, the program name and the process id is included. The date and time are taken from the received message. If the format of the timestamp field is incorrect, time obtained from the local host is used instead. This can be overridden by the -T flag. Accesses from UDP socket can be filtered by libwrap configuration files, like /etc/hosts.deny. Specify ``syslogd'' in daemon_list portion of the configuration files. Refer to hosts_access(5) for details. SYSLOG PROTOCOL NOTES syslogd accepts messages in traditional BSD Syslog or in newer Syslog Protocol format. See RFC 3164 (BSD Syslog) and RFC 5424 (Syslog Proto- col) for detailed description of the message format. Messages from the local kernel that are not tagged with a priority code receive the default facility LOG_KERN and priority LOG_NOTICE. All other untagged messages receive the default facility LOG_USER and priority LOG_NOTICE. FILES
/etc/syslog.conf The configuration file. /var/run/syslogd.pid The process id of current syslogd. /var/run/log Name of the UNIX domain datagram log socket. /dev/klog The kernel log device. SEE ALSO
logger(1), syslog(3), services(5), syslog.conf(5), newsyslog(8) The BSD syslog Protocol, RFC, 3164, August 2001. The Syslog Protocol, RFC, 5424, March 2009. HISTORY
The syslogd command appeared in 4.3BSD. Support for multiple log sockets appeared in NetBSD 1.4. libwrap support appeared in NetBSD 1.6. BSD
October 15, 2009 BSD
All times are GMT -4. The time now is 09:19 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy