Results 1 to 3 of 3
I haven't used grep or regular expressions before.
I need to find all files (in the /etc directory) that have two extensions, so I need to search for: anything.anything.anything
Here's ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 04-14-2007 #1Just Joined!
- Join Date
- Apr 2007
- Posts
- 1
grep regular expression help
I haven't used grep or regular expressions before.
I need to find all files (in the /etc directory) that have two extensions, so I need to search for: anything.anything.anything
Here's the command I've pieced together with a little help from Google: ls /etc | grep -e "*\.*\.*"
I've been tweaking it a little bit but it always gives me zero results.
All hints, nudges, and explanations are appreciated.
- 04-14-2007 #2Just Joined!
- Join Date
- Dec 2006
- Location
- Sweden
- Posts
- 8
In this particular case you don't need regular expressions at all. The easiest solution would be:
Code:ls /etc/*.*.*
- 04-14-2007 #3
If you really do require regular expressions for some reason, you were pretty close. Try with the expression '.*\..*\..*'
Example:
Make sure to use single quotes (not double quotes). You don't want those asterisks to expand on the command line.Code:[hector@troy ~]$ ls /var/log | grep '.*\..*\..*' boot.log.1 boot.log.2 boot.log.3 boot.log.4 Xorg.0.log


Reply With Quote
