小编use*_*742的帖子

如何使用echo命令编写和追加到文件

我正在尝试编写一个脚本,它将使用echo和write/append到文件.但我已经在字符串中使用了""..说..

echo "I am "Finding" difficult to write this to file" > file.txt
echo "I can "write" without double quotes" >> file.txt
Run Code Online (Sandbox Code Playgroud)

任何人都可以帮助理解这一点,真的很感激.

BR,SM

shell scripting

16
推荐指数
2
解决办法
6万
查看次数

计算 shell 脚本每一步的时间并显示总执行时间

我有下面的脚本,并且对于一个要求,我必须为每个脚本放置一些函数以获取每个脚本的时间信息并最后显示总时间。

我的主要脚本如下所示:

/u01/scripts/stop.sh ${1} | tee ${stop_log}    
/u01/scripts/kill_proc.sh ${1} | tee ${kill_log}    
/u01/scripts/detach.sh ${1}| tee ${detach_log}   
/u01/scripts/copy.sh ${1} | tee ${copy_log}   
Run Code Online (Sandbox Code Playgroud)

我想使用类似下面的函数来获取每个脚本执行时间,最后使用全局变量我可以显示所有脚本所花费的总时间。

我在下面创建,但不幸的是我无法正确使用,如果你在这里有什么帮助的话。

time_check()    
{         
  export time_log=${log}/time_log_${dts}.log          
  echo 'StartingTime:'date +%s > ${time_log}       
  echo 'EndingTime:'date +%s >> ${time_log}           
}          
Run Code Online (Sandbox Code Playgroud)

我想使用类似上面的函数来获取每个脚本执行时间,最后使用全局变量我可以显示所有脚本所花费的总时间。任何人都可以请指导如何获得所需的结果。

unix linux bash shell scripting

5
推荐指数
1
解决办法
524
查看次数

标签 统计

scripting ×2

shell ×2

bash ×1

linux ×1

unix ×1