About a script in .sh [closed]

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








up vote
-3
down vote

favorite












since yesterday I've been trying to run a command in my script called sed it processes a text and don't tell me that there is any errors but when I check inside the file it just suppresses the text that was supposed to be replaced.



Can someone help me with this ?



Here is my code :



#!/bin/bash
echo "Bienvenue dans l'outils d'ajout à la base de données sur les Animés"
echo "Pour commencez veuillez taper le titre de l'animé dans ce format-ci"
echo "exemple_pour_tester ; Sans majuscules ni espaces"
cat ~/mal-project/anime_template >> ~/mal-project/sources/anime-list
echo -n "Mal-Database ->"
read $titre
echo "processing..."
sed -i "s/titre/$titre/" ~/mal-project/sources/anime-list









share|improve this question















closed as unclear what you're asking by Byte Commander, dessert, Andrea Lazzarotto, Eric Carvalho, muru Feb 25 at 13:53


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.










  • 2




    Please have a look at "How to create a Minimal, Complete, and Verifiable example." Also, I doubt that read $titre what you want. Lastly, there is no way to tell whether the sed command does what you want without having a sample input file and your desired output file.
    – John1024
    Feb 23 at 21:48











  • I tried the command manually and it worked perfectly. It doesn't always need and in and out input
    – Guillaume Girardin Guiguimo
    Feb 23 at 21:54











  • In this case at least, that is not true. Without your sample input, there is no way of knowing whether you actually have the curly braces in your input file.
    – John1024
    Feb 23 at 22:20











  • Strictly speaking, this question is not related to Ubuntu but would fit better to Stack Overflow.
    – PerlDuck
    Feb 23 at 22:47














up vote
-3
down vote

favorite












since yesterday I've been trying to run a command in my script called sed it processes a text and don't tell me that there is any errors but when I check inside the file it just suppresses the text that was supposed to be replaced.



Can someone help me with this ?



Here is my code :



#!/bin/bash
echo "Bienvenue dans l'outils d'ajout à la base de données sur les Animés"
echo "Pour commencez veuillez taper le titre de l'animé dans ce format-ci"
echo "exemple_pour_tester ; Sans majuscules ni espaces"
cat ~/mal-project/anime_template >> ~/mal-project/sources/anime-list
echo -n "Mal-Database ->"
read $titre
echo "processing..."
sed -i "s/titre/$titre/" ~/mal-project/sources/anime-list









share|improve this question















closed as unclear what you're asking by Byte Commander, dessert, Andrea Lazzarotto, Eric Carvalho, muru Feb 25 at 13:53


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.










  • 2




    Please have a look at "How to create a Minimal, Complete, and Verifiable example." Also, I doubt that read $titre what you want. Lastly, there is no way to tell whether the sed command does what you want without having a sample input file and your desired output file.
    – John1024
    Feb 23 at 21:48











  • I tried the command manually and it worked perfectly. It doesn't always need and in and out input
    – Guillaume Girardin Guiguimo
    Feb 23 at 21:54











  • In this case at least, that is not true. Without your sample input, there is no way of knowing whether you actually have the curly braces in your input file.
    – John1024
    Feb 23 at 22:20











  • Strictly speaking, this question is not related to Ubuntu but would fit better to Stack Overflow.
    – PerlDuck
    Feb 23 at 22:47












up vote
-3
down vote

favorite









up vote
-3
down vote

favorite











since yesterday I've been trying to run a command in my script called sed it processes a text and don't tell me that there is any errors but when I check inside the file it just suppresses the text that was supposed to be replaced.



Can someone help me with this ?



Here is my code :



#!/bin/bash
echo "Bienvenue dans l'outils d'ajout à la base de données sur les Animés"
echo "Pour commencez veuillez taper le titre de l'animé dans ce format-ci"
echo "exemple_pour_tester ; Sans majuscules ni espaces"
cat ~/mal-project/anime_template >> ~/mal-project/sources/anime-list
echo -n "Mal-Database ->"
read $titre
echo "processing..."
sed -i "s/titre/$titre/" ~/mal-project/sources/anime-list









share|improve this question















since yesterday I've been trying to run a command in my script called sed it processes a text and don't tell me that there is any errors but when I check inside the file it just suppresses the text that was supposed to be replaced.



Can someone help me with this ?



Here is my code :



#!/bin/bash
echo "Bienvenue dans l'outils d'ajout à la base de données sur les Animés"
echo "Pour commencez veuillez taper le titre de l'animé dans ce format-ci"
echo "exemple_pour_tester ; Sans majuscules ni espaces"
cat ~/mal-project/anime_template >> ~/mal-project/sources/anime-list
echo -n "Mal-Database ->"
read $titre
echo "processing..."
sed -i "s/titre/$titre/" ~/mal-project/sources/anime-list






command-line bash sed






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 23 at 21:38

























asked Feb 23 at 21:31









Guillaume Girardin Guiguimo

22




22




closed as unclear what you're asking by Byte Commander, dessert, Andrea Lazzarotto, Eric Carvalho, muru Feb 25 at 13:53


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.






closed as unclear what you're asking by Byte Commander, dessert, Andrea Lazzarotto, Eric Carvalho, muru Feb 25 at 13:53


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.









  • 2




    Please have a look at "How to create a Minimal, Complete, and Verifiable example." Also, I doubt that read $titre what you want. Lastly, there is no way to tell whether the sed command does what you want without having a sample input file and your desired output file.
    – John1024
    Feb 23 at 21:48











  • I tried the command manually and it worked perfectly. It doesn't always need and in and out input
    – Guillaume Girardin Guiguimo
    Feb 23 at 21:54











  • In this case at least, that is not true. Without your sample input, there is no way of knowing whether you actually have the curly braces in your input file.
    – John1024
    Feb 23 at 22:20











  • Strictly speaking, this question is not related to Ubuntu but would fit better to Stack Overflow.
    – PerlDuck
    Feb 23 at 22:47












  • 2




    Please have a look at "How to create a Minimal, Complete, and Verifiable example." Also, I doubt that read $titre what you want. Lastly, there is no way to tell whether the sed command does what you want without having a sample input file and your desired output file.
    – John1024
    Feb 23 at 21:48











  • I tried the command manually and it worked perfectly. It doesn't always need and in and out input
    – Guillaume Girardin Guiguimo
    Feb 23 at 21:54











  • In this case at least, that is not true. Without your sample input, there is no way of knowing whether you actually have the curly braces in your input file.
    – John1024
    Feb 23 at 22:20











  • Strictly speaking, this question is not related to Ubuntu but would fit better to Stack Overflow.
    – PerlDuck
    Feb 23 at 22:47







2




2




Please have a look at "How to create a Minimal, Complete, and Verifiable example." Also, I doubt that read $titre what you want. Lastly, there is no way to tell whether the sed command does what you want without having a sample input file and your desired output file.
– John1024
Feb 23 at 21:48





Please have a look at "How to create a Minimal, Complete, and Verifiable example." Also, I doubt that read $titre what you want. Lastly, there is no way to tell whether the sed command does what you want without having a sample input file and your desired output file.
– John1024
Feb 23 at 21:48













I tried the command manually and it worked perfectly. It doesn't always need and in and out input
– Guillaume Girardin Guiguimo
Feb 23 at 21:54





I tried the command manually and it worked perfectly. It doesn't always need and in and out input
– Guillaume Girardin Guiguimo
Feb 23 at 21:54













In this case at least, that is not true. Without your sample input, there is no way of knowing whether you actually have the curly braces in your input file.
– John1024
Feb 23 at 22:20





In this case at least, that is not true. Without your sample input, there is no way of knowing whether you actually have the curly braces in your input file.
– John1024
Feb 23 at 22:20













Strictly speaking, this question is not related to Ubuntu but would fit better to Stack Overflow.
– PerlDuck
Feb 23 at 22:47




Strictly speaking, this question is not related to Ubuntu but would fit better to Stack Overflow.
– PerlDuck
Feb 23 at 22:47










1 Answer
1






active

oldest

votes

















up vote
3
down vote



accepted










There are two major issues in your script.




  1. to read something from stdin and put it in a variable called titre you need



    read titre


    (without a preceeding $). This will put your input into
    the variable $titre.




  2. To replace the literal word titre with the content
    of the variable $titre you need



    sed -i "s/titre/$titre/" ~/mal-project/sources/anime-list



The curlies ($titre vs. $titre) are only needed to make clear where a variable ends if the situation is ambigious. Consider you want to replace the literal titre with the content of the variable $titre plus the text deux. The naive approach would be



s/titre/$titredeux/


But here titre would be replaced with nothing (empty string) because there is no variable $titredeux. Hence, we write



s/titre/$titredeux/


instead to make clear that the variable is actually just $titre.






share|improve this answer





























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    3
    down vote



    accepted










    There are two major issues in your script.




    1. to read something from stdin and put it in a variable called titre you need



      read titre


      (without a preceeding $). This will put your input into
      the variable $titre.




    2. To replace the literal word titre with the content
      of the variable $titre you need



      sed -i "s/titre/$titre/" ~/mal-project/sources/anime-list



    The curlies ($titre vs. $titre) are only needed to make clear where a variable ends if the situation is ambigious. Consider you want to replace the literal titre with the content of the variable $titre plus the text deux. The naive approach would be



    s/titre/$titredeux/


    But here titre would be replaced with nothing (empty string) because there is no variable $titredeux. Hence, we write



    s/titre/$titredeux/


    instead to make clear that the variable is actually just $titre.






    share|improve this answer


























      up vote
      3
      down vote



      accepted










      There are two major issues in your script.




      1. to read something from stdin and put it in a variable called titre you need



        read titre


        (without a preceeding $). This will put your input into
        the variable $titre.




      2. To replace the literal word titre with the content
        of the variable $titre you need



        sed -i "s/titre/$titre/" ~/mal-project/sources/anime-list



      The curlies ($titre vs. $titre) are only needed to make clear where a variable ends if the situation is ambigious. Consider you want to replace the literal titre with the content of the variable $titre plus the text deux. The naive approach would be



      s/titre/$titredeux/


      But here titre would be replaced with nothing (empty string) because there is no variable $titredeux. Hence, we write



      s/titre/$titredeux/


      instead to make clear that the variable is actually just $titre.






      share|improve this answer
























        up vote
        3
        down vote



        accepted







        up vote
        3
        down vote



        accepted






        There are two major issues in your script.




        1. to read something from stdin and put it in a variable called titre you need



          read titre


          (without a preceeding $). This will put your input into
          the variable $titre.




        2. To replace the literal word titre with the content
          of the variable $titre you need



          sed -i "s/titre/$titre/" ~/mal-project/sources/anime-list



        The curlies ($titre vs. $titre) are only needed to make clear where a variable ends if the situation is ambigious. Consider you want to replace the literal titre with the content of the variable $titre plus the text deux. The naive approach would be



        s/titre/$titredeux/


        But here titre would be replaced with nothing (empty string) because there is no variable $titredeux. Hence, we write



        s/titre/$titredeux/


        instead to make clear that the variable is actually just $titre.






        share|improve this answer














        There are two major issues in your script.




        1. to read something from stdin and put it in a variable called titre you need



          read titre


          (without a preceeding $). This will put your input into
          the variable $titre.




        2. To replace the literal word titre with the content
          of the variable $titre you need



          sed -i "s/titre/$titre/" ~/mal-project/sources/anime-list



        The curlies ($titre vs. $titre) are only needed to make clear where a variable ends if the situation is ambigious. Consider you want to replace the literal titre with the content of the variable $titre plus the text deux. The naive approach would be



        s/titre/$titredeux/


        But here titre would be replaced with nothing (empty string) because there is no variable $titredeux. Hence, we write



        s/titre/$titredeux/


        instead to make clear that the variable is actually just $titre.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Feb 23 at 22:10

























        answered Feb 23 at 22:01









        PerlDuck

        4,03311030




        4,03311030












            Popular posts from this blog

            pylint3 and pip3 broken

            Missing snmpget and snmpwalk

            How to enroll fingerprints to Ubuntu 17.10 with VFS491