Finds and replaces content in a single file
Path to the file
Pattern to search for
Replacement string
Find and replace options
OperationResult containing FindReplaceResult
const result = await findAndReplaceInFile('/path/to/file.txt', 'oldText', 'newText', { preview: false, createBackups: true});if (result.success) { console.log(`Made ${result.data.replacements} replacements`);} Copy
const result = await findAndReplaceInFile('/path/to/file.txt', 'oldText', 'newText', { preview: false, createBackups: true});if (result.success) { console.log(`Made ${result.data.replacements} replacements`);}
Finds and replaces content in a single file