Difference between revisions of "Append"

From wikieduonline
Jump to navigation Jump to search
Line 8: Line 8:
 
   ForwardAgent yes
 
   ForwardAgent yes
 
  [[END]]
 
  [[END]]
 +
 +
 +
Using <code>[[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 beggining 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 ==
 
== Related ==

Revision as of 16:19, 14 February 2022

echo "your_line_to_append" >> your_file.txt

history -a

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 beggining of lines:
sed s/^./" "/
sed -i s/$/TEST_TO_APPEND_AT_END/ file.txt

Related

See also

Advertising: