Shell 脚本 + 写入文件字符串

标签 shell

我有一个字符串

server.ip=192.168.1.200

而且我需要把上面的语句完全写入文件中。

如何才能做到这一点?

这就是我正在尝试做的...

set client_config = xmlrpc_server.properties
echo 'serverurl=http://'${IP}':8000' >> %${client_config}%
echo 'port=/RPC2' >> %${client_config}%

它不会被添加到文件中。

最佳答案

这对我有用

$ FOO="192.168.1.1"
$ echo "serverurl=http://$FOO:8000" >> x.conf
$ more x.conf
serverurl=http://192.168.1.1:8000

我正在使用 zsh。我也用 bash 验证过。当你这样做时,你会遇到什么问题?

关于Shell 脚本 + 写入文件字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1973420/

相关文章:

linux - 毫米 :ss calculator from shell prompt?

arrays - 使用 bash/awk 将字符串拆分为数组

bash - 如何将多个命令的输出发送到单个 shell 管道?

bash - 在某些情况下,grep的结果与预期不符

shell - shell ksh函数参数包含另一个要调用的函数名称

linux - 如何测试远程服务器是否在 Linux 中启动?

linux - 使用文件作为搜索和替换的输入来查找和替换 shell

linux shell 脚本获取文件夹中 <particular name> 的 <latest file>

php - PHP exec 调用中的重定向创建空文件

linux - 使用 grep 和 * 获取确切的文件名