How can I append to a file using dd?
Solution 1:
You can seek
to the end of the target file:
sudo echo "# New data" |
dd of=/etc/config_file conv=notrunc bs=1 seek=$(stat -f "%z" /etc/config_file)
Solution 2:
Is there any reason you are using dd
rather than output redirection?
The following will work:
echo "# New data" >> /etc/config_file
The >>
means add to the end of file if it exists, otherwise create a new file.