Sponsored Content
Top Forums Shell Programming and Scripting Logical AND operation with egrep Post 302349805 by thegeek on Tuesday 1st of September 2009 10:46:22 PM
Old 09-01-2009
Its not like 'grep' will not work with csv file. It will work with all kind of text file, even with binary files.

But in case of CSV you might be having a separator, so don't forget to include separator in the pattern match.

If the colon is separator then,
Code:
egrep str1:str2:str3

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Egrep cheat sheet anywhere? Looking for meaning of egrep -c

Hi I've been searching google and have not found what egrep -c means. Does anyone know where I can get a cheat sheet or what that -c means? thanks, Linda (2 Replies)
Discussion started by: leelm
2 Replies

2. Shell Programming and Scripting

Array operation

Hi, I would like ask for you help for coding array operation. array= ( a b c d e f ) I would like to remove entry "d" from my array and import the remaining entries back to the array. Thanks. (3 Replies)
Discussion started by: phamp008
3 Replies

3. UNIX for Dummies Questions & Answers

cat operation

Hi, Can anyone explain me what is the functionality of this code cat << EOF > $TSTFILE /$1/ { print "SENT" } EOF Suggestions welcome Thanks in advance (0 Replies)
Discussion started by: trichyselva
0 Replies

4. Shell Programming and Scripting

How to do logical AND and logical OR with grep

Hi can someone please help me on this. I need to perform this code: Grep any lines that meets the following criteria (A AND B) OR (A AND C) I tried this code, but it didn't work Grep-I "A &&B" | "A&&C" *.* $ thanks in advance (12 Replies)
Discussion started by: Needhelp2
12 Replies

5. UNIX for Dummies Questions & Answers

search ")" with egrep - egrep: syntax error

Hi Guys, we have a shell script which basically query the Database which retrieves huge data and use the data with "egrep" . Now there is some data which contains characters like "abc)" and the same is used like below : "egrep (.+\|GDPRAB16\|GDPR/11702 96 abc)\|$ temp.txt" now while... (7 Replies)
Discussion started by: sagarjani
7 Replies

6. UNIX for Dummies Questions & Answers

string operation

I am trying to ask for full name in a script, Then echo back to the user with the surname only, omitting the first name. Thanks (2 Replies)
Discussion started by: orjnet
2 Replies

7. Shell Programming and Scripting

File Operation

I have one text file like 1 filename 2 filename2 3 hi 4 myname i have one variable in which i have index value..i.e.1,2,3 and so... i want to copy value after the index into somevariable..... how i can do it.... (2 Replies)
Discussion started by: AbhijitIT
2 Replies

8. Shell Programming and Scripting

String Operation

/home8/mc09ats/UnixCw/file4 this is the path...i have 2 variables filename and filepath...i want filename=file4 filepath=/home8/mc09ats/UnixCw i.e. i think i have to find last occurence of "/" in string and the string after "/" want to take in some variable and string before last "/"... (4 Replies)
Discussion started by: AbhijitIT
4 Replies

9. Solaris

Operation and Maintenance

I gurus of Solaris, I need to do a Procedure concerning in the Maintenance of Solaris Server. What are the parameters that I must be see Periodically in a Server. For example the space I (df -h) must be each week.- In this server exist a Database aplication (Oracle), and log's that increase or... (4 Replies)
Discussion started by: andresguillen
4 Replies

10. Shell Programming and Scripting

Column operation : cosne and sine operation

I have a txt file with several columns and i want to peform an operation on two columns and output it to a new txt file . file.txt 900.00000 1 1 1 500.00000 500.00000 100000.000 4 4 1.45257346E-07 899.10834 ... (4 Replies)
Discussion started by: shashi792
4 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 08:26 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy