English 中文(简体)
我怎么能够读到在篮子里的圈子中的标准投入,然后将案文附在档案中?
原标题:How can I read standard input in a loop in bash, and then append the text to a file?

我有一只双管齐下的文件。

while
 read $f;
do
 cat $f >> output.txt;
 echo "aaa" >> output.txt;
done

然而,第二个<代码>echo 说明被执行。 总而言之。 我做了什么错误?

I m

tail -f /var/log/somelog | ./script.sh

不应空洞。 只有在<代码>尾<>/代码>通知文件变更时才会产生产出。

最佳回答

可变的<代码>f可能空洞,你的文字正用<条码>的电话加以改动,没有任何理由。 你们想要说吗?

while read f

而不是

while read $f

?

问题回答

暂无回答




相关问题
What does it mean "to write a web service"?

I just asked a question about whether it was possible to write a web-page-checking code and run it from free web server, and one supporter answered and said that it was possible only if I run "a web ...

How can I use exit codes to run shell scripts sequentially?

Since cruise control is full of bugs that have wasted my entire week, I have decided the existing shell scripts I have are simpler and thus better. Here is what I have so far svn update /var/www/...

Dynamically building a command in bash

I am construcing a command in bash dynamically. This works fine: COMMAND="java myclass" ${COMMAND} Now I want to dynamically construct a command that redirectes the output: LOG=">> myfile.log ...

Why does Scala create a ~/tmp directory when I run a script?

When I execute a Scala script from the command line, a directory named "tmp" is created in my home directory. It is always empty, so I simply deleted it without any apparent problem. Of course, when I ...

Ivy, ant and start scripts

I have a project that uses ant to build and ivy for dependencies. I would like to generate the start scripts for my project, with the classpath, based on the dependencies configured in Ivy, ...

热门标签