I have a problem with writing a line in a file using Shell Script. I've tried to use sed and echo, but in both I do not have the expected behavior.
Using sed:
sed -i -e 'export LS_OPTIONS='--color=auto'' /root/.bashrc
Using echo:
echo "eval "'dircolors'"" >> /root/.bashrc
What I believe may be occurring is that sed uses the single quotation mark (') to start and end what should be written, but since what I have to write has single quotation marks, it can not understand what it should be the beginning and the end.
And using echo, as it uses double quotes (") instead of simple ones like sed, it also does not know where the beginning and end of what I want to write.I tried to declare a variable in the script and use echo to write to the file, but it also did not work, I did as follows:
variavel=alias ll='ls $LS_OPTIONS -l'
And then where I want to write, as follows:
echo $variavel >> /root/.bashrc
Does anyone know what I can be doing to write these lines in this file? Or some other command to use in place of echo or thirst. Thanks in advance for all the help.
I apologize if you have become disorganized or some idea expressed in the wrong way. It's my first question that I put here in the stack.