How to silently (in background) create a new line at the end of a specific file, say
/path/to/file.txt (which is not necessarily a visiting file and is not necessarily already open in emacs) and insert some string (say
xyz) in that new line and then to save the file after?
You can use the
write-region functions, for example,
~ $ echo hello > file.txt ~ $ emacs --batch --eval '(append-to-file "xyz\n" nil "file.txt")' ~ $ cat file.txt hello xyz ~ $
(info "(elisp) Writing to Files").