echo命令常用的用法是在终端打印字符串。我们还可以将字符串打印到我们自定义的文件中,即重定位。
例1:
exbot@ubuntu:~/liyijun$ echo "this is my test" > a.txt exbot@ubuntu:~/liyijun$ cat a.txt this is my test
我们使用“>”符号重新创建一个a.txt文档,并且将字符串打印到文档里。
我们再接着执行追加的命令:(>>)
exbot@ubuntu:~/liyijun$ echo "this is my second add" >> a.txt exbot@ubuntu:~/liyijun$ cat a.txt this is my test this is my second add
例2:
在u-boot的代码里有如下几句话:大家可以加深一下印象
echo "ARCH = $2" > config.mk echo "CPU = $3" >> config.mk echo "BOARD = $4" >> config.mk
得到的结果是:
ARCH = arm CPU = s5pc11x BOARD = x210
- 本文固定链接: http://jingyan.idoubi.net/1708.html
- 转载请注明: 游戏创作者大陆 于 逗分享开发经验 发表