How to delete a specific line of a paragraph in AppleScript, while retaining the original format of the text?
Example:

set varText to "
This is sentence 1.
This is sentence 2.
This is sentence 3.
This is sentence 4."

set varText to do shell script "sed -e '1d;3d' &lt;&lt;&lt; " &amp; quoted form of varText


Returns:

"This is sentence 1.
This is sentence 3.
This is sentence 4."




Update: As a result of a discovery mentioned in the Edit: of How to delete a specific line of a “return”-based paragraph in AppleScript?, let me make the following statement:

NOTE: Unfortunately what's returned in this case has carriage return (x0D) characters instead of the expected new line (x0A) characters and in my opinion is a bug!

It's a bug because: The do shell script "sed ..." command when run in Terminal with that varText returns with \n (x0A) not \r (x0D) as it's supposed to. Even the compiled do shell script "sed ..." command in Script Editor still has \n (x0A) not \r (x0D) however why it's being returned with \r (x0D) intend of the expected \n (x0A) is a mystery to me at the moment and I'm going to consider this an AppleScript bug since it not mirroring the expected behavior of the same when run in Terminal.

So, to account for the bug in the results of the do shell script "sed ..." command, this is how I'd handle it. After the do shell script "sed ..." command use the following lines of code:

set newLine to "\n"
set varText to paragraphs of varText
set oldTID to AppleScript's text item delimiters
set AppleScript's text item delimiters to newLine
set varText to varText as string
set AppleScript's text item delimiters to oldTID


Now what's returned contains new line (x0A) characters as it should have to begin with if there wasn't this bug, not carriage return (x0D) characters.



Note: When compiled, the set newLine to "\n" line of code will show as below:

set newLine to "
"