LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 11-07-2011, 05:59 AM   #1
DoME69
Member
 
Registered: Jan 2008
Posts: 147

Rep: Reputation: 15
Smile 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
 
Old 11-07-2011, 06:19 AM   #2
_bsd
Member
 
Registered: Jan 2010
Location: Velveeta, USA
Distribution: Xen, Gentoo,Ubuntu,openSUSE,Debian,pfSense
Posts: 98

Rep: Reputation: 8
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?

Last edited by _bsd; 11-07-2011 at 08:11 AM. Reason: double checked my own facts
 
Old 11-07-2011, 07:56 AM   #3
grail
Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 7,692

Rep: Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987
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?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Num Lock? RIG12 Programming 2 07-02-2007 06:58 PM
Help with NUM GSX Linux - Newbie 6 07-07-2005 01:30 PM
Num Lock always OFF? carlosinfl Fedora 20 03-07-2005 01:51 PM
Num Lock laurentbon Slackware 3 07-01-2003 06:47 AM
Num Lock davecs Linux - Software 5 06-12-2003 08:28 AM


All times are GMT -5. The time now is 03:22 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration