Find the answer to your Linux question:
Results 1 to 3 of 3
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #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.

  2. #2
    Just 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/*.*.*

  3. #3
    Linux Guru anomie's Avatar
    Join Date
    Mar 2005
    Location
    Texas
    Posts
    1,692
    -->
    If you really do require regular expressions for some reason, you were pretty close. Try with the expression '.*\..*\..*'

    Example:
    Code:
    [hector@troy ~]$ ls /var/log | grep '.*\..*\..*'
    boot.log.1
    boot.log.2
    boot.log.3
    boot.log.4
    Xorg.0.log
    Make sure to use single quotes (not double quotes). You don't want those asterisks to expand on the command line.

$spacer_open
$spacer_close

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •