Sed 插入多行 [英] Sed Insert Multiple Lines

查看:64
本文介绍了Sed 插入多行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 sed 进行插入(刚刚阅读了它),但我因尝试插入多行而被难住了?

I'm trying to do an insert with sed (having just read up on it) and i'm being stumped by trying to insert multiple lines?

我目前正在做的是:

sed -i "${line} i\
        /* Name - ID */ \
        select  @ID = NULL \
        from    Animals \
        where   VrsnID = @VrsnID \
        and     Request= \"Request\" \
 \
" animalNames.txt

注意 echo $line == 131

新问题

所有内容都出现在输出的一行中?(也缺少第一个缩进)

Everything appears on one line in the output? (also missing the first indent)

/* Name - ID */        select  @ID = NULL         from    Animals         where   VrsnID = @VrsnID         and     Request= "Request"

已解决

但这会抛出:

sed: -e expression #1, char 47: unknown command: `
'

知道为什么吗?

感谢您的时间

推荐答案

对于新的麻烦:使用双反斜杠 \\

For the new trouble : Use double backslash \\

这篇关于Sed 插入多行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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