The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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
regex anchal_khare Shell Programming and Scripting 3 10-13-2008 06:24 AM
Regex pppswing Shell Programming and Scripting 5 06-30-2008 11:22 PM
Regex deepakpv Shell Programming and Scripting 6 03-28-2007 05:18 AM
Regex?? Please help lunac UNIX for Dummies Questions & Answers 7 01-30-2007 01:13 PM
sed regex Shakey21 UNIX for Dummies Questions & Answers 4 01-31-2002 09:16 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-10-2008
hkansal hkansal is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 69
RegEx for tv5XXXX

Hello Experts,

This is regarding framing RegEx for the likes 'tv5XXXX'.
Their are directories under say 'myFolder/' with names like:

Code:
 
tv5abc1
tv5abc2
tv5jkh6
tv5jkhi
.
.


and others out of my concern. I want to list all the directories of my required type. Their name must fulfill the following condition:
  1. begin with 'tv5'
  2. contain no special character, only alphanumeric
  3. 'tv5' can be followed by 4 alphabets(eg tv5abcd) or 3 alphabets and the last one, a digit(eg tv5abc2).
I made the following towards achieving the solution:


Code:
 
ls -l | awk '{print $9}' | grep "^\(tv5[a-z]\{3,4\}[0-9]\{1\}\)$"

The above snippet lists the likes of tv5ebc1, tv5abc2 etc. and not tv5abcd because it looks for a number in the end.

What I think the solution to be is :

Code:
 
ls -l | awk '{print $9}' | grep "^\(tv5[a-z]\{3\}{--either a digit or an alphabet--}\)$"

Please provide some hints to help me.

Thank You.

Regards
  #2 (permalink)  
Old 12-10-2008
hkansal hkansal is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 69
Smile Resolved(I believe)

I wonder how I missed it.
[0-9a-z]

Problem resolved, I believe.

Final Solution:


Code:
 
ls -l | awk '{print $9}' | grep "^\(tv5[a-z]\{3\}[0-9a-z]\)$"

Still, if you find a test case I might have missed, please help me recognise it.

Thank You.

Regards

PS: I'll post the complete script for review and reference as soon as it is complete.
Closed Thread

Bookmarks

Tags
regex, regular expression conditions, regular expressions

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:14 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0