Sponsored Content
Full Discussion: grep for multiple patterns
Top Forums Shell Programming and Scripting grep for multiple patterns Post 302376215 by rdcwayx on Tuesday 1st of December 2009 02:45:06 AM
Old 12-01-2009
Quote:
Originally Posted by skmdu
Code:
$grep -e "XX" -e "YY" filename

No, this command is wrong:

Code:
$ cat urfile
XX=123|YY=222|ZZ=566
AA=123|EE=222|GG=566
FF=123|RR=222|GG=566
DD=123|RR=222|GG=566
XX=123|YY=222|Zx=566
$ grep -e "XX" -e "YY" urfile
XX=123|YY=222|ZZ=566
XX=123|YY=222|Zx=566

Can use awk:

Code:
 awk -F="|" '/XX/&&/ZZ/' urfile

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

grep for multiple patterns

I want to get a list of all the files in the current directory that have two patterns. I can do first grep of one pattern and then with the output do the grep of the second pattern. if the output of 1st pattern search results in many files, it is very difficult to do a grep of the 2nd pattern for... (1 Reply)
Discussion started by: tselvanin
1 Replies

2. Shell Programming and Scripting

Grep multiple patterns

Hi, Can we grep multiple patterns in UNIX. for example: cat /x/y/oratab | grep -i "pattern1|pattern2" .... etc I require the syntax for multiple patterns. | is not working as I explained in example. Malay (4 Replies)
Discussion started by: malaymaru
4 Replies

3. Shell Programming and Scripting

Grep for Multiple patterns

Hi All, I have a file. I need to find multiple patterns in a row and need those rows to divert to new file. I tried using grep -e / -E / -F options as given in man. But its not working. ==> cat testgrep.txt william,fernandes,xxxxx mark,morsov,yyyy yy=,xx= yyyy=,xxxx== ==>... (7 Replies)
Discussion started by: WillImm123
7 Replies

4. Shell Programming and Scripting

To grep multiple patterns with space in between them......

Hii... Every One...... I want to grep multiple patterns with space in between them. For eg : I have a file which contains following : red cat every one new one you are an ox take one Now, what I want to do is to grep " you are" , "an ox" and "red cat" from this file. Any help........ (5 Replies)
Discussion started by: prashantshukla
5 Replies

5. Shell Programming and Scripting

grep multiple patterns + the whole word only

Guys, i used egrep "pattern1|pattern2". But the whole word is searched. But i want the output if only the exact word is matched. i.e the output is got evenif a part of the pattern is matched. I tried the -w opion but its showing usage error. Please help me out on this one. please sent me... (2 Replies)
Discussion started by: meheretoknow
2 Replies

6. Shell Programming and Scripting

grep multiple patterns in number of files

Hi, I want to list the files containing a no of pattern like for single string i can use grep -l "string" * This command will enlist the files containg this string. Similarly i would like to use for multiple string. I like to enlist file names having string1 and string 2 Can... (3 Replies)
Discussion started by: vikash_k
3 Replies

7. Shell Programming and Scripting

Grep from multiple patterns multiple file multiple output

Hi, I want to grep multiple patterns from multiple files and save to multiple outputs. As of now its outputting all to the same file when I use this command. Input : 108 files to check for 390 patterns to check for. output I need to 108 files with the searched patterns. Xargs -I {} grep... (3 Replies)
Discussion started by: Diya123
3 Replies

8. Shell Programming and Scripting

Grep multiple patterns that contain wildcards

job_count=`grep -e "The job called .* has finished | The job called .* is running" logfile.txt | wc -l` Any idea how to count those 2 patterns so i have a total count of the finished and running jobs from the log file? If i do either of the patterns its works okay but adding them together... (8 Replies)
Discussion started by: finn
8 Replies

9. Shell Programming and Scripting

How to use grep with multiple patterns?

I am trying to grep a variable with multiple lines with multiple patterns below is the pattern list in a variable called "grouplst", each pattern is speerated by "|" grouplst="example1|example2|example3|example4|example5|example6|example7" I need to use the patterns above to grep a... (2 Replies)
Discussion started by: ajetangay
2 Replies

10. UNIX for Beginners Questions & Answers

Grep multiple patterns(file) and replace whole line

I am able to grep multiple patterns which stored in a files. However, how could we replace the whole line with either the pattern or new string? For example: pattern_file: *Info in the () is not part of the pattern file. They are the intended name to replace the whole line after the pattern... (5 Replies)
Discussion started by: wxboo
5 Replies
VTYSH(1)							  Version 0.96.5							  VTYSH(1)

NAME
vtysh - a integrated shell for Quagga routing software SYNOPSIS
vtysh [ -b ] vtysh [ -E ] [ -d daemon ] ] [ -c command ] DESCRIPTION
vtysh is a integrated shell for Quagga routing engine. OPTIONS
Options available for the vtysh command: -b, --boot Execute boot startup configuration. It makes sense only if integrated config file is in use (not default in Quagga). See Info file Quagga for more info. -c, --command command Specify command to be executed under batch mode. It behaves like -c option in any other shell - command is executed and vtysh exits. It's useful for gathering info from Quagga routing software or reconfiguring daemons from inside shell scripts, etc. Note that mul- tiple commands may be executed by using more than one -c option and/or embedding linefeed characters inside the command string. -d, --daemon daemon_name Specify which daemon to connect to. By default, vtysh attempts to connect to all Quagga daemons running on the system. With this flag, one can specify a single daemon to connect to instead. For example, specifying '-d ospfd' will connect only to ospfd. This can be particularly useful inside scripts with -c where the command is targeted for a single daemon. -e, --execute command Alias for -c. It's here only for compatibility with Zebra routing software and older Quagga versions. This will be removed in future. -E, --echo When the -c option is being used, this flag will cause the standard vtysh prompt and command to be echoed prior to displaying the results. This is particularly useful to separate the results when executing multiple commands. -h, --help Display a usage message on standard output and exit. ENVIRONMENT VARIABLES
VTYSH_PAGER This should be the name of the pager to use. Default is more. FILES
/usr/local/etc/vtysh.conf The default location of the vtysh config file. /usr/local/etc/Quagga.conf The default location of the integrated Quagga routing engine config file if integrated config file is in use (not default). WARNING
This man page is intended to be a quick reference for command line options. The definitive document is the Info file Quagga. SEE ALSO
bgpd(8), ripd(8), ripngd(8), ospfd(8), ospf6d(8), isisd(8), zebra(8) BUGS
vtysh eats bugs for breakfast. If you have food for the maintainers try http://bugzilla.quagga.net AUTHORS
See http://www.zebra.org and http://www.quagga.net or the Info file for an accurate list of authors. Quagga VTY shell 27 July 2006 VTYSH(1)
All times are GMT -4. The time now is 10:12 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy