[SOLVED] sed does not remove word done from within shell script
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
sed does not remove word done from within shell script
I am trying to create a script to remove all instances of the word done from within my script. then cat a text file with the word done in it to append the word done at the end of my script so the while loop terminates properly
sed -i "s/done/ /g" /home/dnoob/script
cat text >> /home/dnoob/script
this does append the word done however
after i run the script the sed commands removes
the word done from within the sed command only
is the 'sed' command inside your script that you want to modify??
Please post your script.
Another issue: You do not need to cat the word done from another text file. You can do this with sed:
sed -i "s/ / /g" /home/dnoob/Desktop/scripts/shell.sh
cat dnoob >> /home/dnoob/Desktop/scripts/shell.sh
loop=y
while [ "$loop" = y ] ; do
echo "what does baket mean:" ; read word
if [ "$word" = why ]
then
echo "that is correct"
else
echo "that is not correct"
fi
echo "press (y) to continue (n) to quit" ; read loop
clear
if [ "$loop" = y ]
then
echo "what does maganda mean" ; read word
if [ "$word" = pretty ]
then
echo "good job"
else
echo "that is not correct"
fi
echo "(y) to continue (n) to terminate" ; read loop
clear
fi
if [ "$loop" = y ]
then
echo "what does pogi mean" ; read word
if [ "$word" = handsome ]
then
echo "good job"
else
echo "that is not correct"
fi
echo "(y) to continue (n) to terminate" ; read loop
clear
fi
the sed commnans works the first time i run it sed -i 's/done/ /g;$ a done' /path/to/file
when i look at the script after i run it the word done disappears
sed -i 's/ / /g;$ a '
the purpose of this script is two fold 1 test me in tagalog. 2 is to help me learn shell programming. this is a project i have created for myself once i complete this one i will move on to my next project.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.