CentOS/SSH: append text to file

Hi All,

How do i add text to the bottom of a file using SSH?


Thanks
LVL 2
detox1978Asked:
Who is Participating?
 
woolmilkporcCommented:
ssh user@host 'echo "my new line of text" >> /etc/postfix/virtual'

wmp
0
 
woolmilkporcCommented:
ssh is a secure remote shell and not a text manipulation program.

What exactly is your requirement?

wmp
0
 
detox1978Author Commented:
I want PHP to manage email forwarding.

Currently I connect via SSH and append a line of text to /etc/postfix/virtual using vi

Ideally i'd like to do this via a script online.

0
 
detox1978Author Commented:
That worked thanks.

When i check the file it has blue "^M" at the end of each line, is this important?
0
 
woolmilkporcCommented:
This is because you obviously transferred the file from Windows to Linux in FTP ASCII mode.
It can cause problems, depending on the application.
I assume Postfix is able to handle it correctly, but better use "BINARY" transfer in the future.
The ^M (carriage return) characters are not related to the method of appending text with "echo" and ">>", however.

wmp
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.