0

I want to add "void mainfunction()" on the top of a file. I am reading the actual name of the file from another file and the name of the main function from another file. I was using sed -i '1i void $name_main()' $name_c where the name of the file is stored in name_c and the name_main stores the name of the main function. But this command is inserting void $main_name() at the top of the file. How can I fix this?

0

1 Answer 1

1

I just have to use double quotes instead of single. The command is:

sed -i "1i void $name_main()" $name_c

Not the answer you're looking for? Browse other questions tagged .