Results 1 to 5 of 5

Thread: how to list a file with specific string

  1. #1
    Join Date
    Apr 2008
    Beans
    1

    how to list a file with specific string

    Hi

    I want to list a file with string "r" and "d" in the file name. I have tried the following command but it didn't work

    ls [rd]*

    Plz help

  2. #2
    Join Date
    Apr 2008
    Location
    Ohio
    Beans
    391
    Distro
    Ubuntu 9.04 Jaunty Jackalope

    Re: how to list a file with specific string

    in the directory try:

    Code:
    ls | egrep 'r|d'

  3. #3
    Join Date
    Apr 2008
    Location
    Phoenix, AZ
    Beans
    1,393
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: how to list a file with specific string

    Is the order significant? Does the letters have to be right next to each other?

  4. #4
    Join Date
    May 2007
    Location
    Chennai,India
    Beans
    24
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: how to list a file with specific string

    Try 'grep' with 'ls'.
    For example
    ls | grep "[rd]"

  5. #5
    Join Date
    Apr 2008
    Location
    Phoenix, AZ
    Beans
    1,393
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: how to list a file with specific string

    Quote Originally Posted by ashikahamed View Post
    Try 'grep' with 'ls'.
    For example
    ls | grep "[rd]"
    [rd] can match if only one of the 2 letters is present. I am not sure if he needs to match on both specifically, or just one of them.

Bookmarks

Posting Permissions

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