I want to execute below command using line number as a variable.
sed '5c\ disk = jskdjfdsk' vm.cfg
How do i substitute a variable in place of 5
for example
i tried substituting
sed '$variablec\ disk = jskdjfdsk' vm.cfg
and
sed '"$variable"c\ disk = jskdjfdsk' vm.cfg)
but they didnt worked .
Please help
Scott
2
Double quote your sed and use the variable as ${variable}
i.e.
sed "${variable}c\ disk = jskdjfdsk" vm.cfg
Or put a space after it:
sed "$variable c\ disk = jskdjfdsk" vm.cfg
to separate it from the character c
vino
3
Drop the single quotes and bring in double quotes. Single quotes prevent variable expansion.
Try if this works
sed "${variable}c\ disk = jskdjfdsk" vm.cfg