CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner: recursively find non-ascii characters in file: Edit Log



romild0
Novice

Jan 7, 2009, 1:13 AM


Views: 5170
recursively find non-ascii characters in file

Hi!

I have some nasty, non-ascii character in some files that contains php code. What I want to do here is to recursively find all the files that contains a specific non-ascii character in the file. And most importantly - i need to know the name of that file.

So far, I found a script that looks into a file for non-ascii characters:


Code
while (<>) { 
s/([\x80-\xff])/sprintf "\\x{%02x}",ord($1)/eg;
print;
}


Ok, this is good, the non-ascii character that I'm looking for is:



Code
 
x{ef}\\x{bb}\\x{bf}


The problem here is that i can can't run this script to run recursively and I don't get the name of the file that contains this characters.

I've tried with bash, but since it's standard output, I can't get any resault on this. Here is what I've tried:



Code
 
find |xargs /usr/local/bin/check_for_non-ascii_characters.sh |grep -l 'x{ef}\\x{bb}\\x{bf}'


So, I need a way to recursively find non-ascii characters (a specific pattern, mentioned before) in all files and I need the name of the files containing it.

Thanks


(This post was edited by romild0 on Jan 7, 2009, 1:16 AM)


Edit Log:
Post edited by romild0 (Novice) on Jan 7, 2009, 1:16 AM
Post edited by romild0 (Novice) on Jan 7, 2009, 1:16 AM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives