2

I would like to output a file's contents appended with a string without creating a new line.

so far my command places the appended string on a new line:

sed -e 'a foo' file.txt
>> file contents...
>> foo

I want the output to look like this:

>> file contents...foo
4

1 回答 1

5

使用sed(在Archlinux&上成功测试Minix):

sed '$s/$/foo/' file.txt

$开头,意思是文件的结尾

如果您需要在每行添加foo :

sed 's/$/foo/' file.txt

在最新的上下文中,$平均

于 2012-10-12T00:34:25.313 回答