Sponsored Content
Full Discussion: Explanation of Nawk command
Top Forums UNIX for Beginners Questions & Answers Explanation of Nawk command Post 303032948 by kirans.229 on Wednesday 27th of March 2019 05:25:02 AM
Old 03-27-2019
Code:
{s=s sep $2; sep="|"; next} $0~s {c++} END {print c+0}

In the above, where is it mentioned that it is a 'comma' separated field.

what does 'sep' denotes here. sep="|" i was thinking that it is a pipe separator.

and what does s=s denotes here ?




Moderator's Comments:
Mod Comment Please use CODE tags as required by forum rules!

Last edited by RudiC; 03-27-2019 at 06:27 AM.. Reason: Added CODE tags.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed command explanation needed

Hi, Could you please explain me the below statement -- phrase wise. sed -e :a -e '$q;N;'$cnt',$D;ba' abc.txt > xyz.txt if suppose $cnt contains value: 10 it copies last 9 lines of abc.txt to xyz.txt why it is copying last 9 rather than 10. and also what is ba and $D over there in... (4 Replies)
Discussion started by: subbukns
4 Replies

2. Shell Programming and Scripting

command line explanation

Hello everyone, I found this command line in a website: perl -pi.bak -we's/\z/Your new line\n/ if $. == 2;' your_text_file.txt With this command line you can insert a new line anywhere you want in a text without overwriting what's in it. -p causes perl to assume a loop around your... (4 Replies)
Discussion started by: goude
4 Replies

3. Shell Programming and Scripting

nawk code explanation

Hi I have a line/command which greps certain pattern () from the file and 22 lines AFTER that: nawk '/\/{c=22}c&&c--' input_file Can somebody explain the coding in this command (what " c&&c-- " does)? and how to modify this command to output 22 lines BEFORE this pattern () Thanks a lot ... (3 Replies)
Discussion started by: aoussenko
3 Replies

4. UNIX for Dummies Questions & Answers

SED command explanation

can someone please explain the below sed command.. sed 's/\(*|\)\(.*\)/\2\1/' (6 Replies)
Discussion started by: raghu_shekar
6 Replies

5. UNIX for Dummies Questions & Answers

Explanation of NAWK Code

Hi all, I need your help in understanding the meaning and syntax of the below nawk line. Here is an extract of a script which I use daily and works well. The script extracts the hostnames and messages within a syslog file. I would also like to extract the message time in the 3rd column by... (2 Replies)
Discussion started by: wthomas
2 Replies

6. Shell Programming and Scripting

sed sorting command explanation

sed '$!N; /^\(.*\)\n\1$/!P; D' i found this file which removes duplicates irrespective for sorted or unsorted file. keep first occurance and remove the further occurances. can any1 explain how this is working.. i need to remove duplicates following file. duplicate criteria is not the... (3 Replies)
Discussion started by: mukeshguliao
3 Replies

7. UNIX for Advanced & Expert Users

command explanation

can anyone please tell me what does this expression means , i am under probation and need some explanation :) $AUDIT_DIR -type f -mtime +$AUDIT_EXPIRE \ -exec rm {} > /dev/null 2>&1 \; AUDIT_DIR="/var/log/" AUDIT_EXPIRE='30' Please use code tags! (4 Replies)
Discussion started by: semaan
4 Replies

8. Shell Programming and Scripting

Need explanation a of command in linux

Hi All I ran a script in Linux. In the script i have lines like && echo "Failed: Missing ${CM_ENV_FILE} \n" && return 1 . ${CM_ENV_FILE} Where CM_ENV_FILE = /data/ds/dpr_ebicm_uat//etl/cm3_0/entities/BBME/parameters/cm.env But its taking this path... (1 Reply)
Discussion started by: vee_789
1 Replies

9. UNIX for Dummies Questions & Answers

Explanation of the sort command

Hi everyone, I am wondering if someone could please break down and explain the following sort command for me: ls ${DEST_LOCATION}/${FILES} | sort -rt -k 4,4n | head -1 I have tried working it out using 'man sort', but on AIX there is not a great explanation of this function. I know that... (9 Replies)
Discussion started by: jimbojames
9 Replies

10. Shell Programming and Scripting

sed command explanation

Will someone give me an explanation on how the sed command below works. sed 's/.*//' Thanks! (3 Replies)
Discussion started by: scj2012
3 Replies
Regexp::Common::net(3pm)				User Contributed Perl Documentation				  Regexp::Common::net(3pm)

NAME
Regexp::Common::net -- provide regexes for IPv4 addresses. SYNOPSIS
use Regexp::Common qw /net/; while (<>) { /$RE{net}{IPv4}/ and print "Dotted decimal IP address"; /$RE{net}{IPv4}{hex}/ and print "Dotted hexadecimal IP address"; /$RE{net}{IPv4}{oct}{-sep => ':'}/ and print "Colon separated octal IP address"; /$RE{net}{IPv4}{bin}/ and print "Dotted binary IP address"; /$RE{net}{MAC}/ and print "MAC address"; /$RE{net}{MAC}{oct}{-sep => " "}/ and print "Space separated octal MAC address"; } DESCRIPTION
Please consult the manual of Regexp::Common for a general description of the works of this interface. Do not use this module directly, but load it via Regexp::Common. This modules gives you regular expressions for various style IPv4 and MAC (or ethernet) addresses. $RE{net}{IPv4} Returns a pattern that matches a valid IP address in "dotted decimal". Note that while 318.99.183.11 is not a valid IP address, it does match "/$RE{net}{IPv4}/", but this is because 318.99.183.11 contains a valid IP address, namely 18.99.183.11. To prevent the unwanted matching, one needs to anchor the regexp: "/^$RE{net}{IPv4}$/". For this pattern and the next four, under "-keep" (See Regexp::Common): $1 captures the entire match $2 captures the first component of the address $3 captures the second component of the address $4 captures the third component of the address $5 captures the final component of the address $RE{net}{IPv4}{dec}{-sep} Returns a pattern that matches a valid IP address in "dotted decimal" If "-sep=P" is specified the pattern P is used as the separator. By default P is "qr/[.]/". $RE{net}{IPv4}{hex}{-sep} Returns a pattern that matches a valid IP address in "dotted hexadecimal", with the letters "A" to "F" capitalized. If "-sep=P" is specified the pattern P is used as the separator. By default P is "qr/[.]/". "-sep=""" and "-sep=" "" are useful alternatives. $RE{net}{IPv4}{oct}{-sep} Returns a pattern that matches a valid IP address in "dotted octal" If "-sep=P" is specified the pattern P is used as the separator. By default P is "qr/[.]/". $RE{net}{IPv4}{bin}{-sep} Returns a pattern that matches a valid IP address in "dotted binary" If "-sep=P" is specified the pattern P is used as the separator. By default P is "qr/[.]/". $RE{net}{MAC} Returns a pattern that matches a valid MAC or ethernet address as colon separated hexadecimals. For this pattern, and the next four, under "-keep" (See Regexp::Common): $1 captures the entire match $2 captures the first component of the address $3 captures the second component of the address $4 captures the third component of the address $5 captures the fourth component of the address $6 captures the fifth component of the address $7 captures the sixth and final component of the address This pattern, and the next four, have a "subs" method as well, which will transform a matching MAC address into so called canonical format. Canonical format means that every component of the address will be exactly two hexadecimals (with a leading zero if necessary), and the components will be separated by a colon. The "subs" method will not work for binary MAC addresses if the Perl version predates 5.6.0. $RE{net}{MAC}{dec}{-sep} Returns a pattern that matches a valid MAC address as colon separated decimals. If "-sep=P" is specified the pattern P is used as the separator. By default P is "qr/:/". $RE{net}{MAC}{hex}{-sep} Returns a pattern that matches a valid MAC address as colon separated hexadecimals, with the letters "a" to "f" in lower case. If "-sep=P" is specified the pattern P is used as the separator. By default P is "qr/:/". $RE{net}{MAC}{oct}{-sep} Returns a pattern that matches a valid MAC address as colon separated octals. If "-sep=P" is specified the pattern P is used as the separator. By default P is "qr/:/". $RE{net}{MAC}{bin}{-sep} Returns a pattern that matches a valid MAC address as colon separated binary numbers. If "-sep=P" is specified the pattern P is used as the separator. By default P is "qr/:/". $RE{net}{domain} Returns a pattern to match domains (and hosts) as defined in RFC 1035. Under I{-keep} only the entire domain name is returned. RFC 1035 says that a single space can be a domainname too. So, the pattern returned by $RE{net}{domain} recognizes a single space as well. This is not always what people want. If you want to recognize domainnames, but not a space, you can do one of two things, either use /(?! )$RE{net}{domain}/ or use the "{-nospace}" option (without an argument). REFERENCES
RFC 1035 Mockapetris, P.: DOMAIN NAMES - IMPLEMENTATION AND SPECIFICATION. November 1987. SEE ALSO
Regexp::Common for a general description of how to use this interface. AUTHOR
Damian Conway damian@conway.org. MAINTAINANCE
This package is maintained by Abigail (regexp-common@abigail.be). BUGS AND IRRITATIONS
Bound to be plenty. For a start, there are many common regexes missing. Send them in to regexp-common@abigail.be. LICENSE and COPYRIGHT This software is Copyright (c) 2001 - 2009, Damian Conway and Abigail. This module is free software, and maybe used under any of the following licenses: 1) The Perl Artistic License. See the file COPYRIGHT.AL. 2) The Perl Artistic License 2.0. See the file COPYRIGHT.AL2. 3) The BSD Licence. See the file COPYRIGHT.BSD. 4) The MIT Licence. See the file COPYRIGHT.MIT. perl v5.14.2 2011-12-11 Regexp::Common::net(3pm)
All times are GMT -4. The time now is 01:21 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy