Could you please provide an example of what input you have and what output you expect, people may then be able to provide more accurate suggestions.
Thanks
... by the way, at the beginning of which lines would you like to insert a space ? all ? only some ? which ?
name/date/record/serial (note a single space at beginning of line)
and I am using the sed command
sed 'name c\
name/date/record/$newserial
' <file1 >file2
to change the line with variable $newserial
Problem is it won't keep the space at the beginning of the line, and I want to keep it (for tidy sake).
Secondly I want to do multiple change in a single file but dont' know how to combine the c\ with the -e command in SED, so that I won't have to write multiple SED command in the script which would require to generate a new output file everytime the SED c\ command is called.
Just put a space before the new text and it will be preserved (the bolded, red underscore is where the space would go):
sed '
/pattern1/ c\
_newtext1
/pattern2/ c\
_newtext2
' file
On an unrelated note, if you want to expand the value of a shell variable into the new text, you cannot use single quotes; you must use double quotes instead.
Which shell and operating system are you using? Post the exact code that you tried in the exact way that you invoked it. Post the exact erroneous output and error message that you received. Otherwise, we can't be of any help.