|
|
||||||
|
#1
|
|
|
|
|
egrep Multiple Pattern Search
===================== Example: ======== Requirement : Find the root and oracle users informations from /etc/ passwd [url down] |
|
|
|
#2
|
|
|
|
|
On Oct 8, 3:18 pm, tritya <swawsji> wrote:
> egrep Multiple Pattern Search > ===================== > Example: > ======== > Requirement : Find the root and oracle users informations from /etc/ > passwd > [..] $ wget -q -O - 'http://www.nalanta.com/2008/08/12/egrep-multiple- pattern-search/' | sed -ne '/Requirement :/,${s/<[^>]*>//g;s/ \‘/'\''/g;s/e '\''/e'\''/;p;/#$/q;}' Requirement : Find the root and oracle users informations from /etc/ passwd [root@tritya root]# egrep 'root|oracle' /etc/passwd root:x:0:0:root:/root:/bin/bash oracle:x:300:200:oracle:/home/oracle:/bin/bash [root@tritya root]# $ No, that's not a very good answer. That would also match lines such as: devil:x:100:100:root of all evil:/home/devil: Better answers: # egrep '^root:|^oracle:' /etc/passwd # grep -e '^root:' -e '^oracle:' /etc/passwd # sed -ne '/^root:/p;/^oracle:/p' /etc/passwd # awk -F: '{if($1=="root"||$1=="oracle")print;}' /etc/pass |
|
|
| Similar Threads | |
| egrep pattern match problem Hi, I am trying to extract codes from a file, that only have 4 numbers after the 'EDT.' example file: EDT.1299 EDT.53992 EDT.34013 EDT.solide |
|
| how do i perform a unique multiple string search using grep/egrep I'm trying to determine the HBA card type using prtdiag output. A prtdiag o/p for the io cards on a sun server using the command /usr/platform/sun4u/sbin/prtdiag -v | sed... |
|
| Using multiple cells as search pattern. Hi, I'm using excel for an analysis of a communications protocol, and I would like to search for a pattern where two (or more) adjacent cells match some pattern. Say I want... |
|
| Multiple Search Pattern for Directory.GetFiles Is there a way to use multiple search patterns when calling Directory.GetFiles. For instance Directory.GetFiles("C:\MyFolder", "*.aspx") will return all files with the aspx... |
|
|
All times are GMT. The time now is 07:08 PM. | Privacy Policy
|