LinuxQuestions.org
Help answer threads with 0 replies.
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 01-30-2009, 12:01 PM   #1
dodoecchi
LQ Newbie
 
Registered: Jan 2009
Location: France, Lozčre
Posts: 2

Rep: Reputation: 0
Question bash : crop some text with regex


Hello!
I'm new to bash scripting
it seems very powerful so I'm learning

I would like to crop all the xxx-xx from a text file
I tried

Code:
TR=" `grep -e "[0-9][0-9][0-9]-[0-9][0-9]" ~/index.html`"
but grep output the full lines
I just want xxx-xx

I also tried with sed, but I could only replace what I wanted to get...

thanks for any help

Dorian
 
Old 01-30-2009, 12:19 PM   #2
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora, Lubuntu, FreeBSD
Posts: 3,930
Blog Entries: 5

Rep: Reputation: Disabled
I think you mean you want to select xxx-xx from a text file.

See the manpages for grep(1). You most likely want the -o option.
 
Old 01-30-2009, 01:10 PM   #3
dodoecchi
LQ Newbie
 
Registered: Jan 2009
Location: France, Lozčre
Posts: 2

Original Poster
Rep: Reputation: 0
great, thanks a lot!

now how can I store the results in a table?
 
  


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
TextPad-like text editor with regex for linux? nickleus Linux - Software 5 10-19-2010 12:39 PM
Need help with bash + regex onesikgypo Programming 2 01-10-2009 10:08 AM
Regex in bash? BeholdMyGlory Linux - Newbie 4 01-10-2009 08:32 AM
text manipulation, REGEX plus the following line farkus888 Solaris / OpenSolaris 3 02-27-2007 06:26 PM
Can you parse text with regex? raypen Slackware 4 03-21-2006 12:26 PM


All times are GMT -5. The time now is 05:47 PM.

Main Menu
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