我使用以下命令创建名为usersuspend.sh
的启动脚本echo "sleep 2" > usersuspend.sh
echo "am force-stop com.android.deskclock" >> usersuspend.sh
现在,书面文件如下所示:
sleep 2
am force-stop com.android.deskclock
该脚本强制com.android.deskclock关闭。
问题是:如果我希望相同的脚本关闭更多应用程序,那么文件应如下所示:
sleep 2
am force-stop com.android.deskclock
am force-stop application2
am force-stop application3
如果是这样,我只是继续为每一行添加此命令:
echo "am force-stop application2" >> usersuspend.sh
这只会附加到现有文件吗?是双>>物?因为在第一行有一个>
答案 0 :(得分:0)
这只会附加到现有文件吗?是双>>重要?
是和是 - 请参阅manual:
… >file Standard output is redirected to file. If file does not ex- ist, it is created; if it does exist, is a regular file, and the noclobber option is set, an error occurs; otherwise, the file is truncated. Note that this means the command cmd <foo >foo will open foo for reading and then truncate it when it opens it for writing, before cmd gets a chance to actually read foo. >|file Same as >, except the file is truncated, even if the noclobber option is set. >>file Same as >, except if file exists it is appended to instead of being truncated. Also, the file is opened in append mode, so writes always go to the end of the file (see open(2)). …