• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 898
  • Last Modified:

CentOS/SSH: append text to file

Hi All,

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


Thanks
0
detox1978
Asked:
detox1978
  • 3
  • 2
1 Solution
 
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
 
woolmilkporcCommented:
ssh user@host 'echo "my new line of text" >> /etc/postfix/virtual'

wmp
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.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now