egrep regex


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting egrep regex
# 1  
Old 06-30-2009
egrep regex

Hi,

I have a file with some words divided into syllables by the character "|" (pipe).
For example zu|ri|ghe|se.I would like a regex that matches all the words that are not divided in syllables.All the word that have no "|" pipe character.I have thought at

$echo "zu|ri|ghe|se" | grep '[^|]'

But it doesn't work.Why?Thank you.
# 2  
Old 06-30-2009
Quote:
Originally Posted by and77
Hi,

I have a file with some words divided into syllables by the character "|" (pipe).
For example zu|ri|ghe|se.I would like a regex that matches all the words that are not divided in syllables.All the word that have no "|" pipe character.I have thought at

$echo "zu|ri|ghe|se" | grep '[^|]'

But it doesn't work.Why?Thank you.
could you give an example for 'the word that have no "|" pipe character'?
# 3  
Old 06-30-2009
Do you mean something like

Code:
echo "zu|ri|ghe|se" | awk -v RS="|" '{print}'

The question isn't so clear (you said you wanted to find them, but not what you wanted to do with them).
# 4  
Old 06-30-2009
egrep regex

I would like to put into a file the words that haven't the pipe character.
for example

gru|vie|ra
gru|ye|re
gruzzo
gruzzolo
gua|ca|mo|le
guac|co
gua|co

into the file will be putted

gruzzo
gruzzolo
because there is no pipe character.Thank you.
# 5  
Old 06-30-2009
try awk..
Code:
awk '!/\|/' filename

# 6  
Old 06-30-2009
grep -v '|' filename
# 7  
Old 06-30-2009
Code:
nawk -F'|' 'NF==1' myFile

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sendmail K command regex: adding exclusion/negative lookahead to regex -a@MATCH

I'm trying to get some exclusions into our sendmail regular expression for the K command. The following configuration & regex works: LOCAL_CONFIG # Kcheckaddress regex -a@MATCH +<@+?\.++?\.(us|info|to|br|bid|cn|ru) LOCAL_RULESETS SLocal_check_mail # check address against various regex... (0 Replies)
Discussion started by: RobbieTheK
0 Replies

2. Shell Programming and Scripting

Perl, RegEx - Help me to understand the regex!

I am not a big expert in regex and have just little understanding of that language. Could you help me to understand the regular Perl expression: ^(?!if\b|else\b|while\b|)(?:+?\s+){1,6}(+\s*)\(*\) *?(?:^*;?+){0,10}\{ ------ This is regex to select functions from a C/C++ source and defined in... (2 Replies)
Discussion started by: alex_5161
2 Replies

3. UNIX for Dummies Questions & Answers

read regex from ID file, print regex and line below from source file

I have a file of protein sequences with headers (my source file). Based on a list of IDs (which are included in some of the headers), I'd like to print out only the specified sequences, with only the ID as header. In other words, I'd like to search source.txt for the terms in IDs.txt, and print... (3 Replies)
Discussion started by: pathunkathunk
3 Replies

4. Shell Programming and Scripting

Regex for HP egrep

I seem to be having an issue with an egrep command and I think its the way it is interpreting my regex. I have a test file.. ###FIND THESE### telnet /telnet `telnet -l` ###Dont FIND THESE### donotfindtelnet telnetdontfind Working Regex on Linux/Solaris egrep '\<(telnet|rcp)\>' $file ... (4 Replies)
Discussion started by: nitrobass24
4 Replies

5. Shell Programming and Scripting

matching a regex using egrep not working

Hi, I'm trying to validate if a string matches a regular expression, but it is not working. Am I missing something? Do I need to scape any of the characters? if echo 'en-GB' | egrep '({1,8})(-{1,8})*' >/dev/null; then echo Valid value fi Thanks in advance (6 Replies)
Discussion started by: skrtxao
6 Replies

6. Shell Programming and Scripting

regex question using egrep

Hi, i have a a bunch of directories that are always named with six lowercase alpha's and either one or two numeric's (but no more) so for example names could be qwerty1 qwerty9 qwerty10 qwerty67 I am currently using two pattern matches to capture these names echo $DIR |... (8 Replies)
Discussion started by: rethink
8 Replies

7. Shell Programming and Scripting

Regex/egrep matching numbers in brackets

Experts: I don't know that regular expressions will ever be easy for me, so if one of you guru's could help out, I'd appreciate it. I'm trying to match a line in our syslog, but I can't figure out how to match a number inside a bracket. This is what I'm trying to match. "Jul 16 00:01:34... (2 Replies)
Discussion started by: jdveencamp
2 Replies

8. Shell Programming and Scripting

Converting perl regex to sed regex

I am having trouble parsing rpm filenames in a shell script.. I found a snippet of perl code that will perform the task but I really don't have time to rewrite the entire script in perl. I cannot for the life of me convert this code into something sed-friendly: if ($rpm =~ /(*)-(*)-(*)\.(.*)/)... (1 Reply)
Discussion started by: suntzu
1 Replies

9. 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

10. 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
Login or Register to Ask a Question