-2

for documentation need i have a shell scripts, where i have to add certain string at the start and end in the shell scripts in a given line, the line number is random and contain in the list

for example :-  
test.sh 
line number := 2,5,6,7,9
Add "&gt" "/&gt"

in test.sh file go to the line number 2 and add "&gt" in the start of the line and "/&gt" at the end of the line do the same for line number 5,6,7,9
4

2 回答 2

1

在 awk 中,您可以测试是否NRinpatsplit().

于 2012-06-02T05:29:10.310 回答
1
sed -i~ '2{s/^.*$/"\&gt"&"\\\&gt"/}' FILE

2是行号。"\&gt""\\\&gt"分别是前缀和后缀(你需要转义&\)。您将拥有一个后缀为~.

于 2012-06-02T05:29:25.107 回答