开发者

appending text to all files that starts with a string

How do I append a string to all the files in a directory that starts with a particular string?

I tried,

cat mysig >> F*

But instead of appending co开发者_StackOverflowntents of mysig to all files starting with F, it creates a file named "F*". Obviously wildcard doesn't seem to work. Any alternatives? Thanks in advance.

Edit: Also how do I delete this newly created file "F*" safely?. Using

rm F*

would delete all the files starting with F which I wouldn't want.


The shell can't do that directly, since there will only be a single stream coming from the source program (the cat, in this case).

You need a helper program, such as tee. Try this:

$ cat mysig | tee -a F*


for f in F*
do
  echo "string" >> $f
done

* is a special character - you need to quote it

rm 'F*'
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜