0

How can i insert a text in the last line of a file in linux

Hello,
need to edit the last line of file without entering into the file . how can enter the word using command

CentOS Ubuntu Add a comment
gabriel
asked Nov 26 2019

Answer

0

Use the following command,
cat <<EOT >> /root/sample.txt

Output:

cat <<EOT >> sample.txt
> test
> sample
> -bash: warning: here-document at line 12 delimited by end-of-file (wanted `EOT')
cat sample.txt
test
sample
test

Note:

Press Ctrl + d to terminate the end of the file.

Add a comment
linuxhelp
asked Nov 26 2019
edited Nov 26 2019
Post your Answer