Closed. This question needs to be more focused。它当前不接受答案。
                            
                        
                    
                
                            
                                
                
                        
                            
                        
                    
                        
                            想改善这个问题吗?更新问题,使其仅通过editing this post专注于一个问题。
                        
                        4年前关闭。
                                                                                            
                
        
在bash shell脚本中,在文件的最后10行中搜索单词。如果找到,请执行一项操作,否则执行另一项操作


  我必须在log.out中搜索“服务器已启动”,如果找到,则需要
  执行以下命令

service httpd start

最佳答案

这是您可以做到的:

result=`tail --lines=10 log.out | grep "Server started"`
if [[ "$result" == ""]]; then
   ...
else
   ...
fi

09-11 06:40
查看更多