I changed my password and username for mySQL and I need to replace the connection string in all of my PHP scripts accordingly. I am having trouble with the command because many of my php file names contain spaces. What can I change to make this command work without having "No such file or directory" errors? Here is the command I am using:
I am unfamiliar with xargs and sed and I copied this code from this answer to a similar question. (I think I will put the mysql_connect statement into a php include file and only change it in one place next time.) I'm running Ubuntu 14.04 LTS using BASH I'd like to search for suspicious php-files on a linux machine. Currently I have a solution for large strings, but few days ago I found a new version of a suspicious script. Instead of just setting a variable in one long line, the new version splits the line into chunks and concat it. Here is a sample:
and so on. That why I'd like to search for this pattern, where Base64 Parts are concat together with a dot like here. Is there a way to do it with Linux Tools without writing a new short program? asked Jan 19, 2018 at 20:21
6 On a Linux system, you could use something like:
Which tells grep to recursively look for files that contain at least 20 sequential characters from the Base64 alphabet; matching files have their filename printed. Adjust the 20 to taste. answered Jan 19, 2018 at 20:39
Jeff Schaller♦Jeff Schaller 64.3k33 gold badges104 silver badges235 bronze badges 2 See more: The filename is files_in_dir.php file1.txt contains: AAAAAAAA file2.txt contains: AAAAAAAA We are searching for "CCCCCCCC" pattern and want to know its line number and echo $line_number of each file. That's all! What I have tried: <?php $files = array_diff(scandir("files_test"), array('..', '.')); echo getcwd()."\n"; echo "THINGS IN WORKING DIRECTORY"; foreach (scandir('.') as $file) echo $file . "\n"; echo "\n"; foreach($files as $file) { echo $file."\n"; $search = "CCCCCCCC"; $lines = file($file); $line_number = false; while (list($key, $line) = each($lines) and !$line_number) { $line_number = (strpos($line, $search) !== FALSE) ? $key + 1 : $line_number; } echo "The line number is: ".$line_number."\n"; } ?> $lines = file('"'.$file.'"'); Why are you adding the quote characters around the file name? Just use the simple variable as described at PHP: file - Manual[^]. This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL) CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900 |