![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Linux RedHat, Ubuntu, SUSE, Fedora, Debian, Mandriva, Slackware, Gentoo linux, PCLinuxOS. All Linux questions here! |
|
|
||||
| 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 12:00 PM |
| Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`" | Lokesha | UNIX for Dummies Questions & Answers | 4 | 12-19-2007 10:52 PM |
| No utpmx entry: you must exec "login" from lowest level "shell" | peterpan | UNIX for Dummies Questions & Answers | 0 | 01-18-2006 01:15 AM |
| "sed -n expression " fails. Why? | grahamb | Shell Programming and Scripting | 2 | 12-14-2005 10:44 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Regular expression to extract "y" from "abc/x.y.z" .... i need regular expression
Regular expression to extract "y" from "abc/x.y.z"
|
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
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 12:30 AM. Reason: Add Perl example |
|
#3
|
|||
|
|||
|
Hi,
sed 's/.*\.\(.*\)\..*/\1/' using cut : cut -d"." -f2 Thanks Penchal |
|||
| Google The UNIX and Linux Forums |
| Tags |
| regex, regular expressions |
| Thread Tools | |
| Display Modes | |
|
|