Adding a new line to an existing text file

(imported topic written by FITZPAW91)

Hi,

I have searched the forum for a way to do this, and all I have found is how to find an existing line and change it. This is not what I want. I am sure it is very easy, but I am still stuck. It probably uses

appendfile {concatenation “%0d%0a” of

but I can’t figure out the syntax.

Thanks

William

(imported comment written by NoahSalzman)

Try this one:

http://forum.bigfix.com/viewtopic.php?id=1961

(imported comment written by FITZPAW91)

Thanks

But this replaces an existing line

try something like this, replacing “line you’d like to add” with your line:

I need to add new data, and not replace anything.

William

(imported comment written by NoahSalzman)

Try this action:

// store the file location

parameter “filename” = “C:\somefile.txt”

// add some new text

appendfile {concatenation of lines of file (parameter “filename”) & “%0d%0a” & “some new text” & “%0d%0a”}

// backup the old file (first delete any old backup files)

delete “{parameter “filename”}.bak”

move “{parameter “filename”}” “{parameter “filename”}.bak”

// replace with the new file

move __appendfile “{parameter “filename”}”

(imported comment written by FITZPAW91)

Hi Noah

That worked, thanks for the help

William