Skip to main content

text

Merge text files using PHP code

the easiest and best way is to use the below code

 

<?php

$txt1 = file_get_contents('1.txt');
$txt1 .= "\n" . file_get_contents('2.txt');
$txt1 .= "\n" . file_get_contents('3.txt');

$fp = fopen('newText.txt', 'w');
if(!$fp)
    die('Could not create / open text file for writing.');
if(fwrite($fp, $txt1) === false)
    die('Could not write to text file.');

echo 'Text files have been merged.';

?>

How do I find all files containing specific text on Linux?

How do I find all files containing specific text on Linux?

grep -rnw '/path/to/somewhere/' -e 'pattern'
  • -r or -R is recursive,
  • -n is line number, and
  • -w stands for match the whole word.
  • -l (lower-case L) can be added to just give the file name of matching files.
  • -e is the pattern used during the search

Along with these, --exclude--include--exclude-dir flags could be used for eff