Concatenation with LF (linefeed) in Linux

(imported topic written by nicoya91)

I’ve reviewed all the code snippets I could find in forums involving the concatenation command and editing text files, but not found an example of concatenating with a line feed in Linux.

I would like to take a file that contains:

line1

line2

line3

and simply append

line4

Using various codes examples in the forums, I tried:

Q: concatenation “%0d%0a” of (lines of file “/tmp/test”) & (“line4”)

A: line1%0d%0aline2%0d%0aline3line4

Figuring the "%0d%0"a might not be working because it designates the CR+LF that’s specific to Windows, I tried specifying the LF only:

Q: concatenation “%0a” of (lines of file “/tmp/test”) & (“line4”)

A: line1%0aline2%0aline3line4

So… any ideas on specifying LF on Linux using the concatenation inspector?

(imported comment written by jessewk)

Hi nicoya,

You need to use slightly different relevance and also the relevance debugger will render the literal %0d%0a in the result string, whereas if you run the relevance as an argument to the createfile command in an action script so that the result is written to a file on disk, you will see that the file does in fact get created with the appropriate line breaks.

You action script would look like this:

createfile until END_OF_FILE
{concatenation “%0d%0a” of ((lines of file “/tmp/test”) ; (“line4”))}
END_OF_FILE

Regards,

Jesse

(imported comment written by nicoya91)

This basically worked, but I had to make a minor syntax tweak to resolve a “command substitutation” failure every time the concatenation line ran - below is what finally worked for me:

createfile until END_OF_FILE
{concatenation “%0d%0a” of (lines of file “/tmp/test”) & (“line4”)}
END_OF_FILE

move “/tmp/test” "/tmp/test.bak"
move __createfile “/tmp/test”