2020年2月22日 星期六

[Linux 常見問題] grep + add time out after some time if not find the relevant match

Source From Here
Question
I use the following command syntax to search params in my script
# grep -qsRw -m1 "any_param" /dir/..../

Some times the search take a very long time. The question is how to add time out to grep command. For example after 20 seconds grep will break out

How-To
There is a Linux command timeout that can do this for you. For example:
# time grep -R -m 1 -e "pattern to search" Github/

real 0m3.627s
user 0m1.824s
sys 0m1.798s


# echo $?
1 // Return code from command grep

# timeout 2s grep -R -m 1 -e "pattern to search" Github/ // Force the grep to timeout after 2 second
# echo $?
124 // Return code from command timeout


1 則留言:

  1. If you're trying to burn fat then you certainly have to start using this brand new personalized keto meal plan diet.

    To create this keto diet, licensed nutritionists, fitness trainers, and top chefs have joined together to develop keto meal plans that are efficient, painless, money-efficient, and satisfying.

    Since their grand opening in January 2019, 1000's of people have already completely transformed their body and well-being with the benefits a great keto meal plan diet can offer.

    Speaking of benefits: clicking this link, you'll discover 8 scientifically-certified ones offered by the keto meal plan diet.

    回覆刪除

[Git 常見問題] error: The following untracked working tree files would be overwritten by merge

  Source From  Here 方案1: // x -----删除忽略文件已经对 git 来说不识别的文件 // d -----删除未被添加到 git 的路径中的文件 // f -----强制运行 #   git clean -d -fx 方案2: 今天在服务器上  gi...