Regular Exprasions


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Regular Exprasions
# 1  
Old 03-27-2013
Regular Exprasions

HI i am new to Unix&LInux world my question is
what dose the question mark ins this command mean
Code:
find . –type d –name “?d*” –print

i tried to to run it without it did not notice any change.
Thx.

Last edited by Scrutinizer; 03-27-2013 at 03:23 PM..
# 2  
Old 03-27-2013
That's a wildcard, not a regular expression ("?" stands for a single character).

Some implementations of "find" support "regex" and "iregex" flags.
This User Gave Thanks to verdepollo For This Post:
# 3  
Old 03-27-2013
Any single character.

See Shell Command Language (and note that find uses pattern matching notation, not regular expressions as such).
This User Gave Thanks to CarloM For This Post:
# 4  
Old 03-27-2013
In case the previous comments were too cryptic, the command:
Code:
find . –type d –name "?d*" –print

will look for files in or under the current directory (.) of type directory (-type d) with a name that is any single character followed by the letter d followed by zero or more other characters (-name "?d*"and prints the pathnames of any files that match these criteria (-print).

Note that I used "?d*", not ?d*. Although opening- and closing-double-quote characters may be nicer visually when typing text, plain double-quote characters are required when passing arguments to the shell (unless you're actually looking for files with names containing the opening- and closing-double-quote characters).

Also note that the -print primary is not needed in this find command because it just specifies the default behavior in this case.
These 2 Users Gave Thanks to Don Cragun For This Post:
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Perl: How to read from a file, do regular expression and then replace the found regular expression

Hi all, How am I read a file, find the match regular expression and overwrite to the same files. open DESTINATION_FILE, "<tmptravl.dat" or die "tmptravl.dat"; open NEW_DESTINATION_FILE, ">new_tmptravl.dat" or die "new_tmptravl.dat"; while (<DESTINATION_FILE>) { # print... (1 Reply)
Discussion started by: jessy83
1 Replies

2. Shell Programming and Scripting

regular expression

Could anyone of you please guide me on making correct regular expression to match the exact word or character I have some numbers like 12345780 extn 1234 1234567 x 43545 13245678 Extn 454857 if * ]]; then VAR3=`echo "$NUMBER" | nawk -F "*" '{print $1 $2}'` ... (4 Replies)
Discussion started by: nram_krishna@ya
4 Replies

3. Shell Programming and Scripting

help in regular expression

<ATTR name="ABCDEFGH" value=""/> <ATTR name="HJYR" value=""/> what would be the regular expression to match both the above strings... Always end with value=""/> always start with <ATTR name=" the ATTR name can be anything.. I need to use this with match() in awk. Thanks.. (1 Reply)
Discussion started by: shekhar2010us
1 Replies

4. Shell Programming and Scripting

Regular expression

I have a flat tab delimited file of the following format 1 A:23 A:45 A:789 2 A:2 A:47 3 A:78 A:345 A:9 A:10 4 A:34 A:98 I want to modify the file to the following format with insertions of "//" in between 1 A:23 // A:45 // A:789 2 A:2 // A:47 3 A:78 // A:345 // A:9 // A:10 4 A:34... (7 Replies)
Discussion started by: Lucky Ali
7 Replies

5. Shell Programming and Scripting

Regular Expression.

can someone let me know what this means in english. \(abcd\) \ is an escape key right? Thanks Also im getting confused with something like it does this mean any single character? and this would be 2 characters ? Just let me know if im on the right track. (5 Replies)
Discussion started by: syco__
5 Replies

6. Shell Programming and Scripting

vi Regular Expression help - can this be done?

Good day! I'll say right away that I'm not good at regular expressions. I'm very much so still learning them and I wasn't sure if this was technically an emergency to post in the emergency forum. I have a task at work here that requires me to insert a string after matching another string... (8 Replies)
Discussion started by: jtollefson
8 Replies

7. Shell Programming and Scripting

regular expression [^ ]

Hi, Could anybody explain why will evaluate to true for a string that is not null, not empty string, and has at least one non-space char? My understanding is that ^ means exclude all chars inside . So I thought it should mean anything except space. This seems a big mystery to me. (9 Replies)
Discussion started by: iengca
9 Replies

8. Linux

Regular expression to extract "y" from "abc/x.y.z" .... i need regular expression

Regular expression to extract "y" from "abc/x.y.z" (2 Replies)
Discussion started by: rag84dec
2 Replies

9. UNIX for Dummies Questions & Answers

regular expressions

how to find for a file whose name has all characters in uppercase after 'project'? I tried this: find . -name 'project**.pdf' ./projectABC.pdf ./projectABC123.pdf I want only ./projectABC.pdf What is the regular expression that correponds to "all characters are capital"? thanks (8 Replies)
Discussion started by: melanie_pfefer
8 Replies

10. Shell Programming and Scripting

regular expression

Hello All! I have a file thats something like this: ( a grep output) /path/of/file/filename.abc.xyz.pqr:! Commented text /path/of/file/filename.abc.xyz: ! More Commented text I need to grep out those line from this file whose filename has ".abc" in the filename (anywhere in filename)... (3 Replies)
Discussion started by: ag79
3 Replies
Login or Register to Ask a Question