这是一个脚本,它从文件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'是多余的。你只需要一个或另一个。 –