Ubuntu – Add words to a text file using a single terminal command (no editors)

command lineeditingtext;

I'm new to Linux. I need to edit a .conf file from the open terminal only and not using any text editors. That is, can I add words and sentences to a config file from an open terminal?

Example: command /home/.../file.conf -add 'abcd' to the 23rd line and so on. And finally, save it.

Is it possible to search a specific word in that config file and add new text to the next line of that config file using only the command?

Best Answer

I usually do this way when I am programming my script to do same what you are asking but programmatically.

echo "Hello you!" >> myfile.txt
echo "this is 2nd line text" >> file.txt
echo "last line!" >> file.txt

Voila! You got it. Important to note >> means adding new line to existing file meanwhile > just simply overwrite everything.