sed adding a new line not working

The file which is used is

/abc/apps/cobbbbbb/apps/abadv/binder/axyz.bnd
/abc/apps/cobbbbbb/apps/abbrio/binder/na6115.bnd
/abc/apps/cobbbbbb/apps/abbrio/binder/kc22.bnd
/abc/apps/cobbbbbb/apps/abbrio/binder/tr4823.bnd
/abc/apps/cobbbbbb/apps/abcmp/binder/cpc0105.bnd

The commads which I ran through are:

sed '/axyz.bnd/ a\grant permissions given  ' file1 

and

sed '/axyz.bnd/  i\grant permissions given  ' file1

If above commands are given it is showing an error so i added a '\'

sed '/axyz.bnd/  i\grant permissions given \ ' file1

..This time no error but no output..Pls help

What are you exactly trying to achieve?
You may also try this:

sed 's/axyz.bnd$/& ===> grant permission/' file
1 Like

Suppose if this text "axyz.bnd" matches then i need to insert a new line with some string value

Please use code tags in your posts!
Standard sed is awful: it wants the insertion text on a new line.

sed '/axyz.bnd/ i\
grant permissions given ' file1 
sed '/axyz.bnd/ a\
grant permissions given ' file1 

(I think the makers of the Unix sed hated the C-shell...)

1 Like