append-once
append-once
is a shell utility that appends a line to a file only once. It is useful for scripts that need to modify configuration files or other persistent files without introducing duplicate lines.
Introduction[edit]
Copy or share this direct link!
Click = Copy
Copied to clipboard!
https://www.kicksecure.com/wiki/Append-once#Introduction
Click below ↴ = Copy to Clipboard
Click = Copy
Copied to clipboard!
[[Append-once#Introduction|Introduction]]
Copy as Wikitext
Click = Copy
Copied to clipboard!
[Introduction](https://www.kicksecure.com/wiki/Append-once#Introduction)
for Discourse, reddit, GitHub
Click = Copy
Copied to clipboard!
[Introduction](https://www.kicksecure.com/wiki/Append-once#Introduction)
Copy as Markdown
Click = Copy
Copied to clipboard!
[url=https://www.kicksecure.com/wiki/Append-once#Introduction]Introduction[/url]
Copy as phpBB
Click below ↴ = Open social URL with share data
We don't use embedded scripts
This share button is completely self-hosted by this webserver. No scripts from any of the social networks are embedded on this webserver. See also
Social Share Button.
- Appends once and is supposed to avoid duplicating the same content, should the exact same lines have already been appended earlier.
- Includes additional sanity testing (checks if the folder where the file resides is writable; checks if the file is readable and writable).
- Offers an easier-to-use interface. [1]
- Write operations are atomic.
- Its write operation is similar to:
printf "%s\n" "text to append" | sponge -a /file/to/append/to >/dev/null
Target Audience[edit]
Copy or share this direct link!
Click = Copy
Copied to clipboard!
https://www.kicksecure.com/wiki/Append-once#Target_Audience
Click below ↴ = Copy to Clipboard
Click = Copy
Copied to clipboard!
[[Append-once#Target_Audience|Target Audience]]
Copy as Wikitext
Click = Copy
Copied to clipboard!
[Target Audience](https://www.kicksecure.com/wiki/Append-once#Target_Audience)
for Discourse, reddit, GitHub
Click = Copy
Copied to clipboard!
[Target Audience](https://www.kicksecure.com/wiki/Append-once#Target_Audience)
Copy as Markdown
Click = Copy
Copied to clipboard!
[url=https://www.kicksecure.com/wiki/Append-once#Target_Audience]Target Audience[/url]
Copy as phpBB
Click below ↴ = Open social URL with share data
We don't use embedded scripts
This share button is completely self-hosted by this webserver. No scripts from any of the social networks are embedded on this webserver. See also
Social Share Button.
Advanced users only!
If append-once
is used in security critical context it should only be used by people capable of reviewing its relatively short and is simple source code.
Syntax[edit]
Copy or share this direct link!
Click = Copy
Copied to clipboard!
https://www.kicksecure.com/wiki/Append-once#Syntax
Click below ↴ = Copy to Clipboard
Click = Copy
Copied to clipboard!
[[Append-once#Syntax|Syntax]]
Copy as Wikitext
Click = Copy
Copied to clipboard!
[Syntax](https://www.kicksecure.com/wiki/Append-once#Syntax)
for Discourse, reddit, GitHub
Click = Copy
Copied to clipboard!
[Syntax](https://www.kicksecure.com/wiki/Append-once#Syntax)
Copy as Markdown
Click = Copy
Copied to clipboard!
[url=https://www.kicksecure.com/wiki/Append-once#Syntax]Syntax[/url]
Copy as phpBB
Click below ↴ = Open social URL with share data
We don't use embedded scripts
This share button is completely self-hosted by this webserver. No scripts from any of the social networks are embedded on this webserver. See also
Social Share Button.
append-once /path/to/file 'line to append'
Example[edit]
Copy or share this direct link!
Click = Copy
Copied to clipboard!
https://www.kicksecure.com/wiki/Append-once#Example
Click below ↴ = Copy to Clipboard
Click = Copy
Copied to clipboard!
[[Append-once#Example|Example]]
Copy as Wikitext
Click = Copy
Copied to clipboard!
[Example](https://www.kicksecure.com/wiki/Append-once#Example)
for Discourse, reddit, GitHub
Click = Copy
Copied to clipboard!
[Example](https://www.kicksecure.com/wiki/Append-once#Example)
Copy as Markdown
Click = Copy
Copied to clipboard!
[url=https://www.kicksecure.com/wiki/Append-once#Example]Example[/url]
Copy as phpBB
Click below ↴ = Open social URL with share data
We don't use embedded scripts
This share button is completely self-hosted by this webserver. No scripts from any of the social networks are embedded on this webserver. See also
Social Share Button.
Click = Copy Copied to clipboard! append-once ~/testfile 'some text here'
Exit Codes[edit]
Copy or share this direct link!
Click = Copy
Copied to clipboard!
https://www.kicksecure.com/wiki/Append-once#Exit_Codes
Click below ↴ = Copy to Clipboard
Click = Copy
Copied to clipboard!
[[Append-once#Exit_Codes|Exit Codes]]
Copy as Wikitext
Click = Copy
Copied to clipboard!
[Exit Codes](https://www.kicksecure.com/wiki/Append-once#Exit_Codes)
for Discourse, reddit, GitHub
Click = Copy
Copied to clipboard!
[Exit Codes](https://www.kicksecure.com/wiki/Append-once#Exit_Codes)
Copy as Markdown
Click = Copy
Copied to clipboard!
[url=https://www.kicksecure.com/wiki/Append-once#Exit_Codes]Exit Codes[/url]
Copy as phpBB
Click below ↴ = Open social URL with share data
We don't use embedded scripts
This share button is completely self-hosted by this webserver. No scripts from any of the social networks are embedded on this webserver. See also
Social Share Button.
- 0: Success.
- Non-Zero: Failure.
Limitations[edit]
Copy or share this direct link!
Click = Copy
Copied to clipboard!
https://www.kicksecure.com/wiki/Append-once#Limitations
Click below ↴ = Copy to Clipboard
Click = Copy
Copied to clipboard!
[[Append-once#Limitations|Limitations]]
Copy as Wikitext
Click = Copy
Copied to clipboard!
[Limitations](https://www.kicksecure.com/wiki/Append-once#Limitations)
for Discourse, reddit, GitHub
Click = Copy
Copied to clipboard!
[Limitations](https://www.kicksecure.com/wiki/Append-once#Limitations)
Copy as Markdown
Click = Copy
Copied to clipboard!
[url=https://www.kicksecure.com/wiki/Append-once#Limitations]Limitations[/url]
Copy as phpBB
Click below ↴ = Open social URL with share data
We don't use embedded scripts
This share button is completely self-hosted by this webserver. No scripts from any of the social networks are embedded on this webserver. See also
Social Share Button.
- Did not support multi-line (with empty lines) at time of writing. Test before use.
Footnotes[edit]
Copy or share this direct link!
Click = Copy
Copied to clipboard!
https://www.kicksecure.com/wiki/Append-once#Footnotes
Click below ↴ = Copy to Clipboard
Click = Copy
Copied to clipboard!
[[Append-once#Footnotes|Footnotes]]
Copy as Wikitext
Click = Copy
Copied to clipboard!
[Footnotes](https://www.kicksecure.com/wiki/Append-once#Footnotes)
for Discourse, reddit, GitHub
Click = Copy
Copied to clipboard!
[Footnotes](https://www.kicksecure.com/wiki/Append-once#Footnotes)
Copy as Markdown
Click = Copy
Copied to clipboard!
[url=https://www.kicksecure.com/wiki/Append-once#Footnotes]Footnotes[/url]
Copy as phpBB
Click below ↴ = Open social URL with share data
We don't use embedded scripts
This share button is completely self-hosted by this webserver. No scripts from any of the social networks are embedded on this webserver. See also
Social Share Button.
- ↑
[1] No need to use:
grep
- considering special characters in
grep
printf
- pipe
>/dev/null
redirection.


Copy as Wikitext

for Discourse, reddit, GitHub

Copy as Markdown

Copy as phpBB Click below ↴ = Open social URL with share data











We believe security software like Kicksecure needs to remain Open Source and independent. Would you help sustain and grow the project? Learn more about our 12 year success story and maybe DONATE!