How do I resolve this sed error when I transfer the script from shell to Makefile?









up vote
0
down vote

favorite












So I have this makefile rule :



header:
rm -f ./include/temp.txt
cat ./srcs/ft_*/ft_*.c | grep -E "^w" | sed 's/$$/;/' | sed '/int main/d' | sed '/inttmain' >> ./include/temp.txt
awk '//; /# define/while(getline<"header.h")print' temp.txt >tmp
mv tmp header.h


I am trying to create a lib project and I have a lot of functions in the ./srcs/ directory, each functions is stored in a ft_name_of_the_function directory. I want to have a Makefile rule that edit the header file of the lib (which is in ./include/ and called header.h) by adding each prototype.



This script was working as a shell executable but doesn't seem to work after I put this in the makefile. I can still tell the makefile to run a shell executable but I would like to understand. When I run make header it gives me this standard output :



rm -f ./include/temp.txt
cat ./srcs/ft_*/ft_*.c | grep -E "^w" | sed 's/$/;/' | sed '/int main/d' | sed '/inttmain' >> ./include/temp.txt
sed: -e expression n°1, caractère 10: expression régulière d'adresse inachevée
Makefile:41: recipe for target 'header' failed
make: *** [header] Error 1









share|improve this question









New contributor




nepriel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



















  • You're welcome. :-)
    – Tim
    Nov 10 at 11:28














up vote
0
down vote

favorite












So I have this makefile rule :



header:
rm -f ./include/temp.txt
cat ./srcs/ft_*/ft_*.c | grep -E "^w" | sed 's/$$/;/' | sed '/int main/d' | sed '/inttmain' >> ./include/temp.txt
awk '//; /# define/while(getline<"header.h")print' temp.txt >tmp
mv tmp header.h


I am trying to create a lib project and I have a lot of functions in the ./srcs/ directory, each functions is stored in a ft_name_of_the_function directory. I want to have a Makefile rule that edit the header file of the lib (which is in ./include/ and called header.h) by adding each prototype.



This script was working as a shell executable but doesn't seem to work after I put this in the makefile. I can still tell the makefile to run a shell executable but I would like to understand. When I run make header it gives me this standard output :



rm -f ./include/temp.txt
cat ./srcs/ft_*/ft_*.c | grep -E "^w" | sed 's/$/;/' | sed '/int main/d' | sed '/inttmain' >> ./include/temp.txt
sed: -e expression n°1, caractère 10: expression régulière d'adresse inachevée
Makefile:41: recipe for target 'header' failed
make: *** [header] Error 1









share|improve this question









New contributor




nepriel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



















  • You're welcome. :-)
    – Tim
    Nov 10 at 11:28












up vote
0
down vote

favorite









up vote
0
down vote

favorite











So I have this makefile rule :



header:
rm -f ./include/temp.txt
cat ./srcs/ft_*/ft_*.c | grep -E "^w" | sed 's/$$/;/' | sed '/int main/d' | sed '/inttmain' >> ./include/temp.txt
awk '//; /# define/while(getline<"header.h")print' temp.txt >tmp
mv tmp header.h


I am trying to create a lib project and I have a lot of functions in the ./srcs/ directory, each functions is stored in a ft_name_of_the_function directory. I want to have a Makefile rule that edit the header file of the lib (which is in ./include/ and called header.h) by adding each prototype.



This script was working as a shell executable but doesn't seem to work after I put this in the makefile. I can still tell the makefile to run a shell executable but I would like to understand. When I run make header it gives me this standard output :



rm -f ./include/temp.txt
cat ./srcs/ft_*/ft_*.c | grep -E "^w" | sed 's/$/;/' | sed '/int main/d' | sed '/inttmain' >> ./include/temp.txt
sed: -e expression n°1, caractère 10: expression régulière d'adresse inachevée
Makefile:41: recipe for target 'header' failed
make: *** [header] Error 1









share|improve this question









New contributor




nepriel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











So I have this makefile rule :



header:
rm -f ./include/temp.txt
cat ./srcs/ft_*/ft_*.c | grep -E "^w" | sed 's/$$/;/' | sed '/int main/d' | sed '/inttmain' >> ./include/temp.txt
awk '//; /# define/while(getline<"header.h")print' temp.txt >tmp
mv tmp header.h


I am trying to create a lib project and I have a lot of functions in the ./srcs/ directory, each functions is stored in a ft_name_of_the_function directory. I want to have a Makefile rule that edit the header file of the lib (which is in ./include/ and called header.h) by adding each prototype.



This script was working as a shell executable but doesn't seem to work after I put this in the makefile. I can still tell the makefile to run a shell executable but I would like to understand. When I run make header it gives me this standard output :



rm -f ./include/temp.txt
cat ./srcs/ft_*/ft_*.c | grep -E "^w" | sed 's/$/;/' | sed '/int main/d' | sed '/inttmain' >> ./include/temp.txt
sed: -e expression n°1, caractère 10: expression régulière d'adresse inachevée
Makefile:41: recipe for target 'header' failed
make: *** [header] Error 1






sed makefile-errors






share|improve this question









New contributor




nepriel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




nepriel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited Nov 10 at 11:31









Tim

7,7082344




7,7082344






New contributor




nepriel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Nov 10 at 11:13









nepriel

32




32




New contributor




nepriel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





nepriel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






nepriel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











  • You're welcome. :-)
    – Tim
    Nov 10 at 11:28
















  • You're welcome. :-)
    – Tim
    Nov 10 at 11:28















You're welcome. :-)
– Tim
Nov 10 at 11:28




You're welcome. :-)
– Tim
Nov 10 at 11:28












2 Answers
2






active

oldest

votes

















up vote
0
down vote



accepted










This sed command:



sed '/inttmain'


is not formed properly. You need an optional address (or addresses) and an action. If you run this at the command line you get this:



$ sed '/inttmain'
sed: -e expression #1, char 10: unterminated address regex


If you want it to be like the previous one:



sed '/int main/d'


but with a tab instead of a space, you probably want this:



sed '/inttmain/d'


You can combine these by using s+ to match some whitespace:



sed '/ints+main/d'





share|improve this answer




















  • thanks ! I just figure out I forgot that :)
    – nepriel
    Nov 10 at 11:41










  • You're welcome. It happens to us all from time to time!
    – Tim
    Nov 10 at 11:45

















up vote
0
down vote













I just figure out I did some other mistakes so in some case people are trying to do the same thing here is my final code :




cp ./include/initlibft.h ./include/libft.h
rm -f ./include/temp.txt
cat ./srcs/ft_*/ft_*.c | grep -E "^w" | sed 's/$/;/' | sed '/main(/d' >> ./include/temp.txt
awk '//; /# define/while(getline<"./include/temp.txt")print' ./include/libft.h >tmp
mv tmp ./include/libft.h






share|improve this answer








New contributor




nepriel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );






    nepriel is a new contributor. Be nice, and check out our Code of Conduct.









     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53238375%2fhow-do-i-resolve-this-sed-error-when-i-transfer-the-script-from-shell-to-makefil%23new-answer', 'question_page');

    );

    Post as a guest






























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote



    accepted










    This sed command:



    sed '/inttmain'


    is not formed properly. You need an optional address (or addresses) and an action. If you run this at the command line you get this:



    $ sed '/inttmain'
    sed: -e expression #1, char 10: unterminated address regex


    If you want it to be like the previous one:



    sed '/int main/d'


    but with a tab instead of a space, you probably want this:



    sed '/inttmain/d'


    You can combine these by using s+ to match some whitespace:



    sed '/ints+main/d'





    share|improve this answer




















    • thanks ! I just figure out I forgot that :)
      – nepriel
      Nov 10 at 11:41










    • You're welcome. It happens to us all from time to time!
      – Tim
      Nov 10 at 11:45














    up vote
    0
    down vote



    accepted










    This sed command:



    sed '/inttmain'


    is not formed properly. You need an optional address (or addresses) and an action. If you run this at the command line you get this:



    $ sed '/inttmain'
    sed: -e expression #1, char 10: unterminated address regex


    If you want it to be like the previous one:



    sed '/int main/d'


    but with a tab instead of a space, you probably want this:



    sed '/inttmain/d'


    You can combine these by using s+ to match some whitespace:



    sed '/ints+main/d'





    share|improve this answer




















    • thanks ! I just figure out I forgot that :)
      – nepriel
      Nov 10 at 11:41










    • You're welcome. It happens to us all from time to time!
      – Tim
      Nov 10 at 11:45












    up vote
    0
    down vote



    accepted







    up vote
    0
    down vote



    accepted






    This sed command:



    sed '/inttmain'


    is not formed properly. You need an optional address (or addresses) and an action. If you run this at the command line you get this:



    $ sed '/inttmain'
    sed: -e expression #1, char 10: unterminated address regex


    If you want it to be like the previous one:



    sed '/int main/d'


    but with a tab instead of a space, you probably want this:



    sed '/inttmain/d'


    You can combine these by using s+ to match some whitespace:



    sed '/ints+main/d'





    share|improve this answer












    This sed command:



    sed '/inttmain'


    is not formed properly. You need an optional address (or addresses) and an action. If you run this at the command line you get this:



    $ sed '/inttmain'
    sed: -e expression #1, char 10: unterminated address regex


    If you want it to be like the previous one:



    sed '/int main/d'


    but with a tab instead of a space, you probably want this:



    sed '/inttmain/d'


    You can combine these by using s+ to match some whitespace:



    sed '/ints+main/d'






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 10 at 11:22









    Tim

    7,7082344




    7,7082344











    • thanks ! I just figure out I forgot that :)
      – nepriel
      Nov 10 at 11:41










    • You're welcome. It happens to us all from time to time!
      – Tim
      Nov 10 at 11:45
















    • thanks ! I just figure out I forgot that :)
      – nepriel
      Nov 10 at 11:41










    • You're welcome. It happens to us all from time to time!
      – Tim
      Nov 10 at 11:45















    thanks ! I just figure out I forgot that :)
    – nepriel
    Nov 10 at 11:41




    thanks ! I just figure out I forgot that :)
    – nepriel
    Nov 10 at 11:41












    You're welcome. It happens to us all from time to time!
    – Tim
    Nov 10 at 11:45




    You're welcome. It happens to us all from time to time!
    – Tim
    Nov 10 at 11:45












    up vote
    0
    down vote













    I just figure out I did some other mistakes so in some case people are trying to do the same thing here is my final code :




    cp ./include/initlibft.h ./include/libft.h
    rm -f ./include/temp.txt
    cat ./srcs/ft_*/ft_*.c | grep -E "^w" | sed 's/$/;/' | sed '/main(/d' >> ./include/temp.txt
    awk '//; /# define/while(getline<"./include/temp.txt")print' ./include/libft.h >tmp
    mv tmp ./include/libft.h






    share|improve this answer








    New contributor




    nepriel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.





















      up vote
      0
      down vote













      I just figure out I did some other mistakes so in some case people are trying to do the same thing here is my final code :




      cp ./include/initlibft.h ./include/libft.h
      rm -f ./include/temp.txt
      cat ./srcs/ft_*/ft_*.c | grep -E "^w" | sed 's/$/;/' | sed '/main(/d' >> ./include/temp.txt
      awk '//; /# define/while(getline<"./include/temp.txt")print' ./include/libft.h >tmp
      mv tmp ./include/libft.h






      share|improve this answer








      New contributor




      nepriel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.



















        up vote
        0
        down vote










        up vote
        0
        down vote









        I just figure out I did some other mistakes so in some case people are trying to do the same thing here is my final code :




        cp ./include/initlibft.h ./include/libft.h
        rm -f ./include/temp.txt
        cat ./srcs/ft_*/ft_*.c | grep -E "^w" | sed 's/$/;/' | sed '/main(/d' >> ./include/temp.txt
        awk '//; /# define/while(getline<"./include/temp.txt")print' ./include/libft.h >tmp
        mv tmp ./include/libft.h






        share|improve this answer








        New contributor




        nepriel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        I just figure out I did some other mistakes so in some case people are trying to do the same thing here is my final code :




        cp ./include/initlibft.h ./include/libft.h
        rm -f ./include/temp.txt
        cat ./srcs/ft_*/ft_*.c | grep -E "^w" | sed 's/$/;/' | sed '/main(/d' >> ./include/temp.txt
        awk '//; /# define/while(getline<"./include/temp.txt")print' ./include/libft.h >tmp
        mv tmp ./include/libft.h







        share|improve this answer








        New contributor




        nepriel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        share|improve this answer



        share|improve this answer






        New contributor




        nepriel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        answered Nov 10 at 12:18









        nepriel

        32




        32




        New contributor




        nepriel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.





        New contributor





        nepriel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.






        nepriel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.




















            nepriel is a new contributor. Be nice, and check out our Code of Conduct.









             

            draft saved


            draft discarded


















            nepriel is a new contributor. Be nice, and check out our Code of Conduct.












            nepriel is a new contributor. Be nice, and check out our Code of Conduct.











            nepriel is a new contributor. Be nice, and check out our Code of Conduct.













             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53238375%2fhow-do-i-resolve-this-sed-error-when-i-transfer-the-script-from-shell-to-makefil%23new-answer', 'question_page');

            );

            Post as a guest














































































            這個網誌中的熱門文章

            How to read a connectionString WITH PROVIDER in .NET Core?

            Node.js Script on GitHub Pages or Amazon S3

            Museum of Modern and Contemporary Art of Trento and Rovereto