Difference between revisions of "Append"
Jump to navigation
Jump to search
(21 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
+ | Append at the end of a [[file]]: | ||
+ | :<code>[[echo]] "your_line_to_append" >> your_file.txt</code> | ||
− | + | <code>[[history -a]]</code> | |
− | [[ | + | [[tee --append]] ~/.ssh/config << END |
− | |||
− | |||
− | |||
Host localhost | Host localhost | ||
ForwardAgent yes | ForwardAgent yes | ||
[[END]] | [[END]] | ||
+ | |||
+ | Using <code>[[Sed (editor)|sed]]</code> | ||
+ | * [[Append]] a text (TEST_TO_APPEND_AT_BEGINNIG) at the [[beginning]] of a line: | ||
+ | :: <code>[[sed -i]] s/^/TEST_TO_APPEND_AT_BEGINNIG/ file.txt</code> | ||
+ | |||
+ | :: [[Append a space]] at the beginning of lines: | ||
+ | ::: <code>[[sed s/^/" "/]]</code> | ||
+ | |||
+ | * Append a text (TEST_TO_APPEND_AT_END) at the [[end of a line]] (<code>$</code>): | ||
+ | :: <code>sed -i s/$/TEST_TO_APPEND_AT_END/ file.txt</code> | ||
+ | |||
+ | == Related == | ||
+ | * <code>[[lineinfile]]</code> | ||
+ | * [[Shell redirection]]: <code>></code> and <code>>></code> | ||
+ | * [[Prepend]] | ||
+ | * [[list]] | ||
+ | * [[Add line]] | ||
== See also == | == See also == | ||
* {{echo}} | * {{echo}} | ||
* {{tee}} | * {{tee}} | ||
+ | * {{Append}} | ||
[[Category:Computing]] | [[Category:Computing]] |
Latest revision as of 09:47, 19 April 2023
Append at the end of a file:
echo "your_line_to_append" >> your_file.txt
tee --append ~/.ssh/config << END Host localhost ForwardAgent yes END
Using sed
sed -i s/^/TEST_TO_APPEND_AT_BEGINNIG/ file.txt
- Append a space at the beginning of lines:
- Append a text (TEST_TO_APPEND_AT_END) at the end of a line (
$
):
sed -i s/$/TEST_TO_APPEND_AT_END/ file.txt
Related[edit]
lineinfile
- Shell redirection:
>
and>>
- Prepend
- list
- Add line
See also[edit]
Advertising: