0

I'm trying to replace all instances of $timestamp = mysqli_real_escape_string($db_conx, $_POST['Timestamp']); with $timestamp = date("Y-m-d H:i:s"); in all files under /home/user/public_html/

I have tried many variations of the below command but can't seem to get the escaping right!

find /home/user/public_html/ -type f -print0 | xargs -0 sed -i 's/\$timestamp = mysqli_real_escape_string(\$db_conx, \$_POST['\''Timestamp'\'']);/\$timestamp = date(\"Y-m-d H:i:s\");/g'
Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255

1 Answers1

0

I got it thanks to @phk

find /home1/user/public_html/ -type f -print0 | xargs -0 sed -i 's/\$timestamp = mysqli_real_escape_string(\$db_conx, \$_POST\['\''Timestamp'\''\]);/\$timestamp = date("Y-m-d H:i:s");/g'
  • As often (if not always), -print0 and xargs -0 are useless and the command can be replaced by find /home1/user/public_html/ -type f -exec sed -i 's/\$timestamp = mysqli_real_escape_string(\$db_conx, \$_POST\['\''Timestamp'\''\]);/\$timestamp = date("Y-m-d H:i:s");/g' {} + – jlliagre Jan 09 '17 at 02:21