Re: A little regex help please ...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is not very elegant, but:

alf1_tsh> echo "5.1.2" | cut -d "-" -f 1 | cut -d "_" -f 1
5.1.2
alf1_tsh> echo "5.1.2_ABC" | cut -d "-" -f 1 | cut -d "_" -f 1
5.1.2
alf1_tsh> echo "5.1.2-ABC" | cut -d "-" -f 1 | cut -d "_" -f 1
5.1.2

so:

VAR=`echo $f | cut -d "-" -f 1 | cut -d "_" -f 1`

should do it.

Cheers,
Terry.

>Yeah, you did understand but I should have been more clear because my release tress go way back and don't all begin with 5.  We go clear back to 3; so it could be
>
>3.0
>3.1
>3.1-*
>3.1_*
>3.2
>3.2-*
>....
>4.5
>4.5-*
>4.5_*
>...
>5.0
>5.0-*
>5.0_*
>
>There is about 300 directories I'm walking through here.
>
>:b!
>
>Brian D. McGrew { [email protected] || [email protected] }
>--
>> This is a test.  This is only a test!
>  Had this been an actual emergency, you would have been
>  told to cancel this test and seek professional assistance!
>
>-----Original Message-----
>From: [email protected] [mailto:[email protected]] On Behalf Of Mauricio Vergara Ereche
>Sent: Monday, July 10, 2006 7:57 AM
>To: For users of Fedora Core releases
>Subject: Re: A little regex help please ...
>
>El Lunes, 10 de Julio de 2006 10:49, Brian D. McGrew escribi_:
>> Morning all,
>
>hi!
>
>> I'm in a shell script (hey, it's dark in here) in the middle of a 'for f
>> in *' loop and I walking through a list of directories that looks like:
>>
>> 5.1
>> 5.1.1
>> 5.1.1-LINUX
>> 5.1.1-FC3
>> 5.1.1-RH73
>> 5.1.1_debug
>> 5.1.1_debug_O1G
>> 5.1.2
>> 5.1.2-LINUX
>> 5.1.2-FC3
>> 5.1.2-RH73
>> 5.1.2_debug
>> 5.1.2_debug_O1G
>>
>> All of these start with a number.  I'm looking for a simple regex to
>> pick off everything up to and including the last numerical value and
>> throw away everything after the last numerical value.
>
>you could try
>for f in 5.1{,.1,.2}; do
>(That will expand to 5.1, 5.1.1 and 5.1.2)
>
>Did I understood well what you want?
>
>-- 
>Mauricio Vergara Ereche                   User #188365 counter.li.org
>
>-- 
>fedora-list mailing list
>[email protected]
>To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
>
>-- 
>fedora-list mailing list
>[email protected]
>To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
>


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux