sed - Only replace a string only once in the entire file -
i have file wish replace string once in entire file ie first match finds should replaced. sed -i 's/foo/foo1/1'
try following:
sed -i '0,/foo/s//foo1/' file
here,
/foo/
fetch line number of first occurrence of foo, let's #n
then same word searched till line #n
, replaced foo1
Comments
Post a Comment