Find the answer to your Linux question:
Results 1 to 2 of 2
Hi guys, I have encountered a small trouble. I want my command: ls -A | grep ^Fr[on,os]* to match "Front" or "Frost" for example but it matches Fro, Frn, Frs. ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jan 2013
    Posts
    7

    Help with ls and grep.


    Hi guys, I have encountered a small trouble. I want my command:
    ls -A | grep ^Fr[on,os]*

    to match "Front" or "Frost" for example but it matches Fro, Frn, Frs.

    How do i make it match the correct sequence of letters?

    Sent from my Nexus 4 using Tapatalk 2

  2. #2
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,318
    hey,

    as long as Fro is at the start, why not use that as part of the regex? and add the "t" at the end. then just put "n" and "s" in the brackets, e.g.:

    Code:
    ls -A | grep ^Fro[ns]t

Posting Permissions

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