![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Need help in using awk and grep | jisha | Shell Programming and Scripting | 6 | 04-09-2008 11:28 AM |
| how to exclude the GREP command from GREP | yamsin789 | UNIX for Advanced & Expert Users | 2 | 10-04-2007 11:59 PM |
| grep help | ravi raj kumar | UNIX for Dummies Questions & Answers | 3 | 12-13-2006 11:41 PM |
| Grep | pankajkrmishra | Shell Programming and Scripting | 15 | 08-31-2006 11:00 PM |
| Make grep -c display like grep -n? | Jerrad | Shell Programming and Scripting | 2 | 08-24-2006 09:20 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
ls -l | grep *_D_CARM
Hello,
I'm trying to use the above command to produce a list of files ending in _D_CARM. However, when I execute the above it doesn't return anything. If I try ls -l *_D_CARM it shows the contents of every directory ending in _D_CARM Any suggestions?! Cheers, JW. |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
find . -type f -name "*_D_CARM"
|
|
#3
|
|||
|
|||
|
Thanks - actually meant to say I was looking for directories so just changed f to d.
Cheers! JW |
|
#4
|
|||
|
|||
|
Your original command was fine, but you can't use "*" in that sense in grep. Grep uses "regular expressions" which have a different syntax than your shell's wildcards.
grep matches the requested string anywhere on a line, so just take out the *. To say "anything at all" in regular expressions, that's dot (.) followed by asterisk (*). Dot matches one character, any character, and asterisk means repeat the previous character (or character class, or whatever) zero or more times. To restrict to just directories, you can do Code:
ls -l */ | grep _D_CARM |
|
#5
|
||||
|
||||
|
You can use the shell for filename expansion:
Code:
ls -ld *D_CARM/ |
||||
| Google The UNIX and Linux Forums |
| Tags |
| regex, regular expressions |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|