Timeline for Is it possible to add some text at beginning of a file in CLI without making new file?
Current License: CC BY-SA 3.0
13 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jan 7, 2018 at 15:04 | answer | added | drl | timeline score: 0 | |
| Jan 3, 2018 at 5:44 | answer | added | Jasen | timeline score: 0 | |
| Jan 3, 2018 at 2:33 | vote | accept | alhelal | ||
| Jan 3, 2018 at 2:20 | history | edited | Jeff Schaller♦ | CC BY-SA 3.0 |
added 6 characters in body; edited tags; edited title
|
| Jan 3, 2018 at 2:15 | comment | added | Wildcard | @alhelal, aha. Well, in common UNIX/Linux filesystems, appending a couple of lines to a multi-gigabyte file is much, much faster than PRE-pending those lines to the same file. In the latter case, in most if not all filesystems, the entire file needs to be rewritten. | |
| Jan 3, 2018 at 2:05 | comment | added | alhelal | @Wildcard I am sure that this increase hard disk usage after doing this, but concern is in processing time. | |
| Jan 3, 2018 at 1:57 | comment | added | Wildcard |
@alhelal, how big is this file, anyway? Since you're not deleting file1, you can't keep your hard disk usage the same. Perhaps you should append file2 to file1 and then move it over the top of file2. That way you don't create a new file, you just overwrite the old.
|
|
| Jan 3, 2018 at 1:40 | comment | added | alhelal | @don_crissti That means if I want to do this for keeping hard disk usage same at that time, this doesn't work. | |
| Jan 3, 2018 at 1:35 | comment | added | Wildcard | @don_crissti, a valid point, but such tools do so a lot more safely than many shell script authors. Also relevant: How can I safely create and access temp files from shell scripts? | |
| Jan 3, 2018 at 1:29 | comment | added | don_crissti | Almost all tools that edit in-place create a temporary file, just so you know. | |
| Jan 3, 2018 at 1:28 | answer | added | B Layer | timeline score: 3 | |
| Jan 3, 2018 at 1:26 | answer | added | Wildcard | timeline score: 4 | |
| Jan 3, 2018 at 1:20 | history | asked | alhelal | CC BY-SA 3.0 |