Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 01-30-2009, 12:01 PM   #1
LQ Newbie
Registered: Jan 2009
Location: France, Lozčre
Posts: 2

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

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

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

Old 01-30-2009, 12:19 PM   #2
Senior Member
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
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
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?


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 > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:10 PM.

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