Shell Commands/Replace
From MorphOS Library
Replace - Modifies text and binary files by replacing data
FILE/A,PATTERN/K,FIND/K/A,REPLACE/K/A,TO/K,ALL/S,I=INSENSITIVE/S,VERBOSE/S,SIM=SIMULATE/S
FILE - Directory or file pattern
PATTERN - Pattern to be applied on files found with the FILE argument
FIND - Text or binary data to be searched for, \xHH for hex data
REPLACE - Text or binary data to replace every found data with, \xHH for hex data
TO - Path to a directory to store the modified files into, TO cannot be
the directory containing the source file
ALL - Search for matching files recursively and modify original files,
TO and ALL are mutually exclusive arguments
INSENSITIVE - All characters in found file data and PATTERN and will be lower
cased before a compare operation, this also affects characters in
hex data specified via "0x" in the PATTERN option
VERBOSE - Shows all found files and how many patterns were modifed
SIMULATE - The entire operation will only be simulated and no files get modified
Examples:
Scans all #?.readme files in T: and changes dogs to cats in the text:
Replace T:#?.readme FIND "Dog" REPLACE "Cat"
Scans the entire RAM: drive and replaces dogs to cats in all files ending with ".txt" and outputting detailed information of found files and the matches. Simulation is enabled, so no modification takes place:
Replace "RAM:#?" PATTERN "#?.txt" FIND "Dog" REPLACE "Cat" ALL VERBOSE SIM
Convert an IBM text to a modern one by replacing CR+LF (0x0D0A) with just LF (0x0A). Operation is performed in the byte mode, so FIND is two bytes and gets replaced by just one byte:
Replace "RAM:Windows.txt" FIND "\x0d\x0a" REPLACE "\x0a"