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:
or with Perl:
or with awk:
The latter doesn't use regular expressions at all, though.
But really, you need to explain in more detail what the parameters of the problem are.
Last edited by era; 05-29-2008 at 04:30 AM..
Reason: Add Perl example
Hello.
System : opensuse leap 42.3
I have a bash script that build a text file.
I would like the last command doing :
print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt
where :
print_cmd ::= some printing... (1 Reply)
Hi All,
I have 2 pipe delimited files viz., file_old and file_new. I'm trying to compare these 2 files, and extract all the different rows between them into a new_file.
comm -3 < sort file_old < sort file_new > new_file
I am getting the below error:
-ksh: sort: cannot open
But if I do... (7 Replies)
How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address
and column 3 contains “cc” e-mail address to include with same email.
Sample input file, email.txt
Below is an sample code where... (2 Replies)
Hi,
I have line in input file as below:
3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL
My expected output for line in the file must be :
"1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL"
Can someone... (7 Replies)
hello,
I am writting a regular expression that intend to match any tunnel or serial interface but it doesn't mtach any serial sub-interface.
For example, statement should match "Tunnel3" or "Serial0/1" but shouldn't match "Serial0\1.1" (doesn't include dot ".")
I tried the following but... (3 Replies)
I have 2000 files named like "file-fr0000.log", "file-fr1999.log"...
I wanna generate the file names automatically in the following c shell script:
set fr = 0
while ($fr <= 1999)
grep "ENERGY" file-fr$fr.log > data.dat
@ fr = ( $fr + 1 )
end
The above will generate file names... (3 Replies)
Hi Friends,
Can any of you explain me about the below line of code?
mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`
Im not able to understand, what exactly it is doing :confused:
Any help would be useful for me.
Lokesha (4 Replies)