adb_file_replace
Replace text in files on an Android device without writing sed syntax. Supports literal find-and-replace, global or line-specific edits, optional backups, and match counts.
Instructions
Find and replace text in a file on the device. Uses sed internally with proper escaping — exposes a safe interface without requiring sed syntax knowledge. Supports global replacement, line-targeted edits, and optional backup creation. Reports match count.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"path": "<path>",
"find": "<find>",
"replace": "<replace>"
},
"name": "adb_file_replace"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| find | Yes | Text to find (literal string, not regex) | |
| path | Yes | File path on device | |
| root | No | Use root shell for protected paths | |
| backup | No | Create a .bak backup before modifying | |
| device | No | Device serial | |
| global | No | Replace all occurrences (default: true). Set false for first-only. | |
| replace | Yes | Replacement text | |
| lineNumber | No | Restrict replacement to a specific line number |