Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Bash 在导入语句后添加一行_Bash - Fatal编程技术网

Bash 在导入语句后添加一行

Bash 在导入语句后添加一行,bash,Bash,如何在以下导入语句后添加一行 import { NgModule } from '@angular/core'; 我的代码当前未进行更改: sed -i "/\import { NgModule } from '@angular\\/core';\[/ {a\\import { TestModule } from '@angular\\/core'; }" ./target/src/app/app.module.ts 试试下面 sed '/import { NgModule } from

如何在以下导入语句后添加一行

import { NgModule } from '@angular/core';
我的代码当前未进行更改:

sed -i "/\import { NgModule } from '@angular\\/core';\[/ {a\\import { TestModule } from '@angular\\/core';
}" ./target/src/app/app.module.ts
试试下面

sed  '/import { NgModule } from '@angular\\/core';/ a import { TestModule } from '@angular\\/core';' ./target/src/app/app.module.ts

我错过了单引号

sed”/import{NgModule}来自“@angular\\\/core”;/a import{TestModule}来自“@angular\\/core”;”/target/src/app/app.module.ts

为什么在模式的末尾有一个“
\[
”?还有,为什么第一个“
i
”被转义了?因为您的模式包含
/
,典型的做法是对地址使用不同的分隔符。例如
sed'\\\^import{NgModule}…
我遗漏了单引号,所以我修改了。