Searching contents of many, many files on server

Discussion in 'Mac Programming' started by cleo, Jan 5, 2009.

  1. cleo macrumors 65816

    cleo

    Joined:
    Jan 21, 2002
    Location:
    Tampa Bay Area, FL, USA
    #1
    Without going into to much detail: I'm working with a fairly complex script, and said script has some fairly complex plugins. I wrote none of them, but I know my way arond them well enough. All PHP, btw.

    Anyway, a small chunk of code (an embedded stylesheet - just three lines, but three havoc-wreaking lines) is being generated somewhere along the way by one of the many parts of the script (or its plugins). I must kill this code, but I can't figure out where it's coming from.

    If I were working on my local machine, I'd open up every sing file in every single directory & subdirectory and do a multi-file search with BBEdit. But it's on a remote shared server. I still could open all the files, etc etc, but opening them all would take a lot longer.

    This is what I want: I want to say to a little script, "See that directory? I want you to search every file in it, and every nested file all the way down, for the following string. And when you find it, tell me where."

    Unfortunately computers don't speak English. So how can I hunt down the elusive style-generator and squash it once and for all?
     
  2. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #2
    this seems like the perfect job for grep as long as you can get to the filesystem via the terminal.

    the -R switch will search recursively, so you could do something like:
    grep -R "some text from the style" /folder/to/start/from/*

    And it should show you the full path and matching line of any files it finds that match. I don't know anything about BBedit, but once you'd found the offending file(s) it should be simple to grab their paths and edit them.

    -Lee
     

Share This Page