PDA

View Full Version : Metcharacters



achuth
February 19th, 2012, 01:47 PM
Sir,
Please give me the patterns for the following using metacharacters

1. All filenames consisting of two lower-case letters
2. All filenames beginning with p and having a t somewhere

ofnuts
February 19th, 2012, 02:11 PM
Sir,
Please give me the patterns for the following using metacharacters

1. All filenames consisting of two lower-case letters
2. All filenames beginning with p and having a t somewhere


looks like some homework assignment, which is explicitly forbidden here
you don't even tell for which environment. If it's for bash see here: http://www.gnu.org/software/bash/manual/bashref.html#Pattern-Matching
what have you tried so far?

achuth
February 19th, 2012, 02:51 PM
i am a tutor. For the first question the following command is showing wrong results
ls *[a-z]*[a-z]*

please help me on first question only

Vaphell
February 19th, 2012, 03:49 PM
in this case * means 'any sequence of chars including the empty one'
<0+ chars>[a-z]<0+ chars>[a-z]<0+ chars>
you get stuff that is at least 2 chars long because * will match anything over these two base characters. Drop *'s and you will get your 2chars long names

Arndt
February 19th, 2012, 04:14 PM
i am a tutor. For the first question the following command is showing wrong results
ls *[a-z]*[a-z]*

please help me on first question only

I wonder if tutor means the same to you as it does to me,