LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   how can grep from file (num num) (num num) ? (http://www.linuxquestions.org/questions/programming-9/how-can-grep-from-file-num-num-num-num-912297/)

DoME69 11-07-2011 04:59 AM

how can grep from file (num num) (num num) ?
 
Hi...

how can i grep from file only the format of
Quote:

"(number number) (number number)".
I'm using tcsh

example of file

Quote:

kuku bubu papa roro (12 13) ( 14 15)
erer (16 17 ) ( 18 19) lll ooo
(20 21 )____ ( 22 23) qqq www rrrrr
* "____" = space

what i except to get it

Quote:

(12 13) (14 15)
(16 17) (18 19)
(20 21) (22 23)
all spaces should be ordered.

Thanks :)

_bsd 11-07-2011 05:19 AM

grep won't do (exactly) what you've requested.

you're going to have to use sed or perl and delete chars before, between, and after the pattern you seek.

One option of grep, '-o' will print only the matching pattern, however it will
break each match onto its own line, not preserving your pairs.


Maybe that's what your teacher wanted you to figure out on your own?

grail 11-07-2011 06:56 AM

I am curious why you mention your shell unless you have been asked to do as bsd has suggested once you retrieve the correct data in a shell script?


All times are GMT -5. The time now is 07:51 PM.