Difference between revisions of "Append"

From wikieduonline
Jump to navigation Jump to search
Line 10: Line 10:
  
  
Using <code>[[sed]]</code>
+
Using <code>[[Sed (editor)|sed]]</code>
 
* [[Append]] a text (TEST_TO_APPEND_AT_BEGINNIG) at the [[beginning]] of a line:
 
* [[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>
 
:: <code>sed -i s/^/TEST_TO_APPEND_AT_BEGINNIG/ file.txt</code>

Revision as of 16:22, 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: