Find the answer to your Linux question:
Results 1 to 3 of 3
Hello All, Glad they have a newbie forum, as I'm sure that this classifies as a newbie question. I'm working on a project that involves my using GNU grep, and ...
  1. #1
    Just Joined!
    Join Date
    Oct 2009
    Posts
    5

    Question concerning Grep

    Hello All,


    Glad they have a newbie forum, as I'm sure that this classifies as a newbie question. I'm working on a project that involves my using GNU grep, and I'm stuck on a step that is probably easier than I think.

    Take this expression: grep -Pl "\xFF\xD8\xFF" ./*

    This searches through files in current directory and outputs those that match having a file signature of FFD8FF, which are jpegs. What I'm trying to do is to do the same without the -P switch, but I'm woefully unskilled with non-Perl regex. I've tried the -al and -l switches to no avail.

    Also, I have done my research into Google, to quell those who would just say to have me 'google it.' I've been working on this for a couple days now and I thought it's about time to ask someone who perhaps dealt with the same problem.

    Thanks in advance.

  2. #2
    Just Joined! spaceminer143's Avatar
    Join Date
    Nov 2008
    Posts
    20
    I believe that you can make this query work by using a dollar sign and single quotes:

    grep -l $'\xFF\xD8\xFF' ./*

    Enjoy!

  3. #3
    Just Joined!
    Join Date
    Oct 2009
    Posts
    5
    Oh man, thanks a bunch. I never thought to try that because as I believe the texts on the matter dictate, $ is an end of line. But it works!!


Posting Permissions

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