About a script in .sh [closed]
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
command-line bash sed
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.
add a comment |Â
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
command-line bash sed
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 thatread $titre
what you want. Lastly, there is no way to tell whether thesed
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
add a comment |Â
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
command-line bash sed
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
command-line bash sed
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 thatread $titre
what you want. Lastly, there is no way to tell whether thesed
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
add a comment |Â
2
Please have a look at "How to create a Minimal, Complete, and Verifiable example." Also, I doubt thatread $titre
what you want. Lastly, there is no way to tell whether thesed
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
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
3
down vote
accepted
There are two major issues in your script.
to read something from stdin and put it in a variable called
titre
you needread titre
(without a preceeding
$
). This will put your input into
the variable$titre
.To replace the literal word
titre
with the content
of the variable$titre
you needsed -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
.
add a comment |Â
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.
to read something from stdin and put it in a variable called
titre
you needread titre
(without a preceeding
$
). This will put your input into
the variable$titre
.To replace the literal word
titre
with the content
of the variable$titre
you needsed -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
.
add a comment |Â
up vote
3
down vote
accepted
There are two major issues in your script.
to read something from stdin and put it in a variable called
titre
you needread titre
(without a preceeding
$
). This will put your input into
the variable$titre
.To replace the literal word
titre
with the content
of the variable$titre
you needsed -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
.
add a comment |Â
up vote
3
down vote
accepted
up vote
3
down vote
accepted
There are two major issues in your script.
to read something from stdin and put it in a variable called
titre
you needread titre
(without a preceeding
$
). This will put your input into
the variable$titre
.To replace the literal word
titre
with the content
of the variable$titre
you needsed -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
.
There are two major issues in your script.
to read something from stdin and put it in a variable called
titre
you needread titre
(without a preceeding
$
). This will put your input into
the variable$titre
.To replace the literal word
titre
with the content
of the variable$titre
you needsed -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
.
edited Feb 23 at 22:10
answered Feb 23 at 22:01
PerlDuck
4,03311030
4,03311030
add a comment |Â
add a comment |Â
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 thesed
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