![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Linux RedHat, Ubuntu, SUSE, Fedora, Debian, Mandriva, Slackware, Gentoo linux, PCLinuxOS. All Linux questions here! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Development Releases: Linux Mint 4.0 Beta "Fluxbox", 4.0 Alpha "Debian" | iBot | UNIX and Linux RSS News | 0 | 01-04-2008 03:00 PM |
| Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`" | Lokesha | UNIX for Dummies Questions & Answers | 4 | 12-20-2007 01:52 AM |
| No utpmx entry: you must exec "login" from lowest level "shell" | peterpan | UNIX for Dummies Questions & Answers | 0 | 01-18-2006 04:15 AM |
| "sed -n expression " fails. Why? | grahamb | Shell Programming and Scripting | 2 | 12-14-2005 01:44 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Regular expressions, as such, only "match", they don't "extract". Some scripting languages have a facility for returning the part of a regular expression which matched, but it then depends on which language you want.
Without more information about what to look for precisely, the simple answer is that the regular expression "y" will match the letter "y", and the matching (extracted) string will always be "y". If you want the first substring between two periods, that's something like this: Code:
sed -n 's/.*\.\([^.]*\)\..*/\1/p' file Code:
perl -lne 'if (m/\.([^.]*)\./) { print $1 }' file
Code:
awk -F . '{ print $2 }' file
But really, you need to explain in more detail what the parameters of the problem are. Last edited by era; 05-29-2008 at 03:30 AM.. Reason: Add Perl example |
|
||||
|
Hi,
sed 's/.*\.\(.*\)\..*/\1/' using cut : cut -d"." -f2 Thanks Penchal |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Tags |
| regex, regular expressions |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|