0
在下面的代碼中,我們將單詞添加到另一個下面。我想在行尾添加如何在bash中添加一個單詞到一行的末尾?
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
因此,這基本上是一個拼寫檢查器,你想寫出一個輸入文件的副本,刪除一些單詞並替換一些單詞,而不改變折行?你孤立的代碼沒有什麼意義,如果我猜對了,你需要改變大部分代碼,然後才能得到你要求的代碼。 – tripleee
'echo word >> file'在'word'後添加一個換行符。所以你必須讓* previous * echo省略換行符才能在同一行上得到另一個單詞。 – tripleee