Search code examples
regexackgrep

grep - search for "<?\n" at start of a file


I have a hunch that I should probably be using ack or egrep instead, but what should I use to basically look for

<?

at the start of a file? I'm trying to find all files that contain the php short open tag since I migrated a bunch of legacy scripts to a relatively new server with the latest php 5.

I know the regex would probably be '/^<\?\n/'


Solution

  • I RTFM and ended up using:

    grep -RlIP '^<\?\n' *
    

    the P argument enabled full perl compatible regexes.