我在文字中有三行
clm_id double,
actv_clm_id double,
clm_id int,
我想将整个单词clm_id所在的行替换为
clm_id bigint,
actv_clm_id double,
clm_id bigint,
任何指针?
答案 0 :(得分:1)
您可以使用此命令:
sed 's/.*\(^\| \)clm_id\( \|$\).*/clm_id bigint/' input.file
<强>解释强>
/ Delimiter
.* Anything (optional)
\(^\| \) Selects the beginning of the line `^` or `|` a whitespace before the word.
into a capturing group (Note that `(|)` need to get escaped by a `\'
clm_id Selects clm_id
\( \|$\) ... followed by a whitespace or the end of the line `$`
.* Anything (optional)
/ Delimiter
<强>输出:强>
clm_id bigint
actv_clm_id double
clm_id bigint
答案 1 :(得分:0)
这可能适合你(GNU sed):
sed '/\<clm_id\>/c\clm_id bigint,' file