troubleshooting Question

preg_replace not work when string is file generated by shell script

Avatar of thierry91
thierry91 asked on
LinuxPHPShell Scripting
3 Comments1 Solution606 ViewsLast Modified:

I generates log file for bash script :

I want to replace the line break or newline by <BR />
but this not have worked

I have tested to replace sftp by <BR />sftp
with :
$file = 'logs.txt';
$subject = readfile($file);
$remplace = '<BR />sftp';
echo preg_replace('/sftp/u', $remplace, $subject);

but same problem, this not replace sftp by <BR />sftp

the content of logs.txt is :
sftp> cd /products/
sftp> lcd ..
sftp> lcd /data/www/composants/products
sftp> put *

>file logs.txt
give this result : logs.txt: UTF-8 Unicode text

have you idea ?

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros