Help with grep script

 
Thread Tools Search this Thread
Homework and Emergencies Homework & Coursework Questions Help with grep script
# 8  
Old 04-03-2013
grep defaults to RE, and I don't find a solution with RE.
But there are some solutions with ERE (extended regular expression).
Also the example in previous post let me think that you all mean ERE when saying "regular expression":
Code:
^[a-z]{10}$

where {10} is ERE (while \{10\} is RE).
So I suggest to study man egrep
and only take the ERE option from man grep.
# 9  
Old 04-03-2013
There is a solution with either BRE (basic regular expression) or ERE, that does not matter.
# 10  
Old 04-03-2013
Like the previous poster, I can confirm there is a solution to this delightful little problem. And it's not a trick question. The solution is a great demonstration of how useful regular expressions can be.

Hey, original poster, where are you? We'd like to hear what you tried so far, or if the assignment is over. Smilie
# 11  
Old 04-04-2013
I will give a hint: what is the mathematical definition of "odd" and "even"? The answer should help with the regexp.

I hope this helps.

bakunin
# 12  
Old 04-24-2013
After some thinking I got the answer I guess.... group multiples of any 2 characters will give you the even number of characters (including whitespaces).

Now for finding odd exclude the lines which match above pattern
# 13  
Old 04-24-2013
I'm afraid that's pretty vague. But maybe it's better you didn't post anything concrete. I don't know what the rules are about posting a solution to this homework assignment. Smilie Is the class over? Of course, no way to know. Any guidance from the administrators?
# 14  
Old 04-24-2013
Quote:
Originally Posted by hanson44
I don't know what the rules are about posting a solution to this homework assignment. [...]Any guidance from the administrators?
There are no real rules regarding this (btw., this might be a good idea for an amendment), but informally we always have tried to give the students pointers but still leave the work to do it themselves.

Posts with outright, full-blown solutions were typically moderated (set to invisible for normal users) until the thread-o/p posted a solution of his own. Users posting such solutions here usually get a PM explaining the special nature of this board and what we are trying to do here and asking them to contribute accordingly - pointers, but no solutions.

In this case, though, it looks like the thread-o/p has abandoned the thread (he was last active three weeks ago) and if alvincorrea wants to attempt to solve the puzzle he could do so in the normal forae:

Quote:
I have found an interesting problem <<here <link to this thread> >>. The task is to <<problem description>> and my proposed solution is

[code].....[/code]

Could anybody please tell me if this is correct and if not, what is the problem.
I hope this helps.

bakunin
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grep Script

Hi, New to scripting and looking for some help. I am trying to write a script that will search a specified directory for any new or modified files within the last 7 days and display the results. This will be ran daily and emailed? Thanks (18 Replies)
Discussion started by: Con592
18 Replies

2. Shell Programming and Scripting

Help with script - GREP

Hallo gentlemen, i've a problem removing lines from txt file. To make it simple, here is an example: TEXT1.TXT --- contents: 9.9.9.9 geek.net 1.1.1.1 geek.com 2.2.2.2 leet.net TEXT2.TXT --- contents: geek.com coolbar.org I simply do: cat text1.txt | grep -f text2.txt >... (7 Replies)
Discussion started by: mirkocosta
7 Replies

3. Shell Programming and Scripting

Inconsistent `ps -eaf -o args | grep -i sfs_pcard_load_file.ksh | grep -v grep | wc -l`

i have this line of code that looks for the same file if it is currently running and returns the count. `ps -eaf -o args | grep -i sfs_pcard_load_file.ksh | grep -v grep | wc -l` basically it is assigned to a variable ISRUNNING=`ps -eaf -o args | grep -i sfs_pcard_load_file.ksh |... (6 Replies)
Discussion started by: wtolentino
6 Replies

4. UNIX for Dummies Questions & Answers

grep IP script

Hello, I have a command and would like to make that as a script. How do I do that? my command is: grep -Eo +\.+\.+\.+. and i want to have that like grepscript.sh x.txt > IP.txt Can somebody help me? (3 Replies)
Discussion started by: eightball
3 Replies

5. Shell Programming and Scripting

script use min resource ( grep grep)

Hi i wrote script use it as watchdog ( i mean it check another program (pooya) whenever that was killed (closed or crashed) it run another script (pooya_start.sh) to start it, this script work fine and do the job for me , i need help of an expert to tell me (exact command) how to change this... (8 Replies)
Discussion started by: pooyair
8 Replies

6. Shell Programming and Scripting

How to grep sql error in shell script and exit the script?

I need help in the following script. I want to grep the sql errors insert into the error table and exit the shell script if there is any error, otherwise keep running the scripts. Here is my script #!/bin/csh -f source .orapass set user = $USER set pass = $PASS cd /opt/data/scripts echo... (2 Replies)
Discussion started by: allinshell99
2 Replies

7. UNIX for Dummies Questions & Answers

trying to grep the first few lines of a continuos script, and exit the script anyidea

Hi. I am trying to extract the output of the first few lines of a continuos sh script. The when i run it, i wont to grep the the first 20 lines of it for an entry and basically do a crtl z out of it or to that effect, and output the results to a text file. I basically want to script... (5 Replies)
Discussion started by: k00061804
5 Replies

8. Shell Programming and Scripting

Grep within a script

Hi, I am new to this - I have a unix command (below) that I would like to make automated. I would like the script to run the below command line but would like user input for '\' and '\' as these values will change depending on what i'm searching for. Is this possible? if so please help. ... (13 Replies)
Discussion started by: dnash
13 Replies

9. UNIX for Dummies Questions & Answers

grep script

hi guys, i was hoping you could help me out with the following im designing a help site for my work colleagues and would like a little script which would do a grep to check if an application is running on unix for example this is what i do on unix ps -ef | grep mqm and this tells me if... (4 Replies)
Discussion started by: drchris
4 Replies

10. UNIX for Advanced & Expert Users

grep from a script...

This is an extract from a script that i am trying to run. for tim in "2005:00:" "2005:01:" "2005:02:" "2005:03:" "2005:04:" "2005:05:"; do FormString="$tim" echo "grep '$FormString' access.10Aug-1201AM" count=`grep "$FormString" access.10Aug-1201AM | wc -l` ... (1 Reply)
Discussion started by: hamsasal
1 Replies
Login or Register to Ask a Question