Skip to main content
1 of 2

Text processing should be done with shell script. Usually it can be done in one short line:

sed 's;[^0-9]2 TEXT1;& MY TEXT HERE;' text_file.txt

Assuming there wasn't some sort of indentation problem above. Based on what it sounds like you meant though, here's another solution:

sed 's;[^0-9]2 TEXT1;&\'$'\n'' MY TEXT HERE;' text_file.txt

AppleScript is not the right tool for this job.