In the following code we are adding words one under the other. I want to add at the end of a line
doc_in=$1 #document to read
main_d=$2 #dictionary of words
ignored_d=$3 #other dictionary of words
doc_out=$4 #document to write
word="example"
function consult_user() {
echo "word not found:[$word] Accept (a) - Discard (i) - Replace (r):"
read opt
if [ $opt == "a" ]
then
#Here I want to add at the end of a line and not "echo"
echo $word >>$doc_out # me agrega todo con un \n
elif [ $opt == "i" ]
then
echo $word >>$ignored_d
else
read new_w
echo $new_w >>$doc_out
fi
}
consult_user
You can use
sed
command to get it done.