ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Main Area and Open Discussion > General Software Discussion

anyone know a commandline tool to add a line of text to end of a text file?

<< < (3/4) > >>

AbteriX:
Thanks rjbull,
that's very helpfully.

I played around a bit (i like unix tools but i have mostly plain dos commends only):

>To append file1 at the end of file2, type
>        cat file1 >> file2
C:\>type file1 >>file2

To append a line of text at the end of file2, type
C:\>echo "some text" >>file2

To append a line of text at the beginn of file3, type
C:\>echo "some text" >tmpfile && type file3 >> tmpfile && ren tmpfile file3

kartal:
Is it possible to append text to a file without recreating the file? I am just afraid that that would change creation modification dates of the file, and that info is much needed for the file I am working with.

f0dder:
kartal: if you use something like "echo blah >> file.txt", the last-modified will be changed, creation date shouldn't... also, not all tools will be good for this, I'm afraid SED and AWK would read in the entire existing file before appending the line? Bad if you're dealing with huge files :)

kartal:
I do not have any problem with modification date. But I hate to see that creation date has changed.

mouser:
i think i wrote a tiny exe to do this called "addnote" which i include with FARR..

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version