Results 1 to 5 of 5

Thread: regular expressions with grep

  1. #1
    Join Date
    Oct 2004
    Location
    Scotland
    Beans
    642
    Distro
    Ubuntu Development Release

    regular expressions with grep

    I want to search for any occurance of 45104 following any tabs or spaces... I'm new to regular expressions and don't understand why the following is not working.

    egrep '\t+45104' input.txt

    Any pointers?

  2. #2
    Join Date
    Jan 2005
    Location
    Adelaide, Australia
    Beans
    340

    Re: regular expressions with grep

    I just had a try of this myself, and it seems like the tab escape isn't being interpreted properly for some reason. For me, it worked when I used a literal tab instead of a '\t'. You can type a literal tab in the shell by pressing Control-V and then hitting TAB.

    To do what you really want, you need:

    egrep '[<literal-tab><literal space>]+45104' input.txt

    so that it can be tabs OR spaces in front of the number.

  3. #3
    Join Date
    Oct 2004
    Location
    Scotland
    Beans
    642
    Distro
    Ubuntu Development Release

    Re: regular expressions with grep

    That worked! Thanks for the help, much appreciated!

  4. #4
    Join Date
    Jun 2012
    Beans
    1

    Re: regular expressions with grep

    ctrl-v and tab. Great. It works. thanks.

  5. #5
    Join Date
    Feb 2007
    Location
    Romania
    Beans
    Hidden!

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
  •