我需要在本HEAD节结束之前将一些文本插入到 HTML 文件中。
我想:
sed -i "s#</head>#<style> @page { prince-shrink-to-fit: auto }
.repository-with-sidebar.with-full-navigation .repository-content
{width: 950px ! important;} </style>\n</head>#" ${1}"/"${2}"/"${i}.html
Run Code Online (Sandbox Code Playgroud)
我收到一个错误:
sed: 1: command a expects \ followed by text
Run Code Online (Sandbox Code Playgroud)
我只是没有看到我的错误。我什至尝试在样式周围使用单引号。
我想在本HEAD节末尾插入的确切文本是:
<style>
@page { prince-shrink-to-fit: auto }
.repository-with-sidebar.with-full-navigation .repository-content
{width: 950px ! important;}
</style>
Run Code Online (Sandbox Code Playgroud)
编辑:这是确切的命令:
sed -i "s#</head>#<style> @page { prince-shrink-to-fit: auto } .repository-with-sidebar.with-full-navigation .repository-content {width: 950px ! important;} </style>\n</head>#" ${1}"/"${2}"/"${i}.html
Run Code Online (Sandbox Code Playgroud)
编辑 2:为了尝试确保我正确格式化命令,我也在尝试这个:
strToInsert='<style> @page { prince-shrink-to-fit: auto } .repository-with-sidebar.with-full-navigation .repository-content {width: 950px ! important;} …Run Code Online (Sandbox Code Playgroud)