Append to beginning of file

72 views
Skip to first unread message

nob...@gmail.com

unread,
Nov 10, 2018, 7:18:37 AM11/10/18
to Automate
Hey dev,
Is there any way to append the contents to the beginning of the file.
If yes, please share.

Thank you,
Nobin Jacob

Henrik "The Developer" Lindqvist

unread,
Nov 10, 2018, 2:24:09 PM11/10/18
to Automate
That's not how file systems work. Use the File read block to read the entire file, prepend the additional content then use the File write block to replace the entire content (not appending).

nob...@gmail.com

unread,
Nov 15, 2018, 6:34:18 AM11/15/18
to Automate
Okay, but there must be some way to place the file pointer to the beginning of the text file. 🤔

Henrik "The Developer" Lindqvist

unread,
Nov 15, 2018, 1:28:58 PM11/15/18
to Automate
As said, that's not work file systems work. Simply seeking to the beginning of the file would overwrite the data.

tq_bt

unread,
Apr 14, 2022, 11:31:48 AM4/14/22
to Automate
File tags can be edited in this way?

गुरुवार, 15 नवंबर 2018 को 11:58:58 pm UTC+5:30 बजे Henrik "The Developer" Lindqvist ने लिखा:

Henrik "The Developer" Lindqvist

unread,
Apr 14, 2022, 11:51:50 AM4/14/22
to Automate
Probably not, but it depends on what you mean by "tags".

Ricardo Fernández Serrata

unread,
Apr 16, 2022, 5:02:01 AM4/16/22
to Automate
The `dd` shell command can be used for this, but it's tricky, and I don't know how to do it. An easier option is to use other shell commands instead. 1st create a file containing what you want to prepend, then use `cat` cmd on the other file to be concatenated and redirect the Standard Output to the 1st file (make sure you use `>>` instead of `>`, to avoid overwriting). After that, rename the end result to the old (non-prepended) file, to replace it, you can do that using `mv` cmd, or just AM "File move" block

Ricardo Fernández Serrata

unread,
Apr 16, 2022, 5:04:27 AM4/16/22
to Automate
I forgot to say that stdout redirection has no memory limit, so you can prepend data to big files using that method, and nothing will crash
Reply all
Reply to author
Forward
Message has been deleted
0 new messages