這是一個腳本,它從文件replaced.txt中讀取單詞,並在每行中顯示每個單詞的輸出,但是我想在一行中顯示所有輸出。 「replaced.txt」文件如何在shell腳本中獲得單行grep的輸出?
#!/bin/sh echo echo "Enter the word to be translated" read a IFS=" " # Set the field separator set $a # Breaks the string into $1, $2, ... for a # a for loop by default loop through $1, $2, ... do { b= grep "$a" replaced.txt | cut -f 2 -d" " } done
內容下面給出:
hllo HELLO m AM rshbh RISHABH jn JAIN hw HOW ws WAS ur YOUR dy DAY
這個問題不能適當我問,我只需要幫助來把腳本的輸出一條線。
您的腳本不完整。 echo(或'printf')語句在哪裏?花括號和'do' /'done'是多餘的。你只需要一個或另一個。 –