嗨,我正在尝试使用sed将文本添加到文件的第一行
到目前为止,我试过了
#!/bin/bash
touch test
sed -i -e '1i/etc/example/live/example.com/fullchain.pem;\' test
这不起作用
也试过了
#!/bin/bash
touch test
sed -i "1i ssl_certificate /etc/example/live/example.com/fullchain.pem;" test
这似乎也不起作用
奇怪的是,当我尝试
#!/bin/bash
touch test
echo "ssl_certificate /etc/example/live/example.com/fullchain.pem;" > test
当我使用cat test时,我会看到第1行文本
但是只要输入sed -i“2i ssl_certificate_key /etc/example/live/example.com/privkey.pem;”
我无法看到我在第2行可以做的信息,这是ssl_certificate_key /etc/example/live/example.com/privkey.pem;
所以我的问题是夏天
>可以使用sed将文本插入新创建的文件的第1行吗?
>如果是,那么在第一行文本之后插入文本的最佳方式是什么?