Reputation: 157
i was wondering weather is it possible to append data in a file without using cat
command.
I've considered using sed to append data , but as of my knowledge sed only operates after loading the full data into the memory. please do correct me if i'm wrong on this.
Upvotes: 1
Views: 321
Reputation: 6495
Instead of cat, you can also use echo command to do the same.
And ofcourse, >>
operator does it.
Upvotes: 2
Reputation: 476574
If you want to append data to a file, you can simply use the append I/O-redirection >>
. For instance:
echo "first line" > file
echo "next line" >> file
Or you could append an entire file
echo "$(<otherfile)" >> file
This command is however not advisable since it will load the entire file first into memory.
A better way is to use tee
:
tee < otherfile >> file
Upvotes: 4