![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Loop problem with one more problem | aliahsan81 | Shell Programming and Scripting | 3 | 01-07-2009 02:02 AM |
| problem in finding a hardware problem | girish.batra | SUN Solaris | 8 | 09-09-2008 11:10 AM |
| ssh script problem problem | pcjandyala | Shell Programming and Scripting | 2 | 07-31-2008 04:27 PM |
| problem with dd command or maybe AFS problem | Anta | Shell Programming and Scripting | 0 | 08-25-2006 11:10 AM |
| SSH Problem auth problem | budrito | UNIX for Advanced & Expert Users | 1 | 03-17-2004 10:12 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
problem with sed
Hi,
I have this: bash-2.03$ echo $kk <programme start="20090124053000 +0100" channel=\CTele-205.laguiatv.com"> I would like to extract= 20090124053000 But I do: echo $kk |sed -e 's/.*start="\(.*\) .*/\1/' and it gives me: 20090124053000 +0100" I can't understand why this command doesn't works. Any help?? Many thanks! |
|
||||
|
Quote:
Many thanks! It works! and than you for the explication |
|
||||
|
It's known as "greedy matching". The regular expression will always try and match the biggest string that satisfies the specified pattern, which in your case includes the embedded space. In Perl, you can specify "non greedy" matching by following the * with a ?. I think you could also have done... Code:
echo ${kk}| sed -e 's/.*="\([0-9]*\) .* /\1/'
...to isolate the datestamp. Jerry |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|