如何将文本附加到文件? [英] How do I append text to a file?

查看:29
本文介绍了如何将文本附加到文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Linux 中将文本附加到文件的最简单方法是什么?

What is the easiest way to append text to a file in Linux?

我看了这个问题,但接受的答案使用了一个额外的程序 (sed) 我相信 echo 或类似的应该有更简单的方法.

I had a look at this question, but the accepted answer uses an additional program (sed) I'm sure there should be an easier way with echo or similar.

推荐答案

cat >> filename
This is text, perhaps pasted in from some other source.
Or else entered at the keyboard, doesn't matter. 
^D

基本上,您可以将想要的任何文本转储到文件中.CTRL-D 发送一个文件结束信号,它终止输入并将您返回到 shell.

Essentially, you can dump any text you want into the file. CTRL-D sends an end-of-file signal, which terminates input and returns you to the shell.

这篇关于如何将文本附加到文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆