sh

How can I split an mp4 video with ffmpeg every time the volume is zero?

醉酒当歌 提交于 2020-01-06 07:10:17
问题 I need to split a video into many smaller videos. I have tried PySceneDetect and its 2 scene detection methods don't fit my need. The idea is to trigger a scene cut/break every time the volume is very low, every time audio level is less than a given parameter. I think overall RMS dB volume level is what I mean. The purpose is to split an mp4 video into many short videos, each smaller video with short dialog phrases. So far I have a command to get the overall RMS audio volume level. ffprobe -f

Tree of inheritance of Git branches

Deadly 提交于 2020-01-06 07:08:51
问题 Is there any way to replicate an inheritance tree of Git branches in shell? For example, I have local branches b1 , b2 , ... , bN as listed by git branch . Example: ++ b7 <--+ b4 | b8 <--+ b5 +-+ b2 | | ++ b1 <---+ b3 | +-+ b6 So, in the above case I would like to have a variables representing branch names (or their hashes, doesn't matter). I know about binary search tree data structures in shell (at least one approach which is working nicely). The problem is how to get a proper left or right

Bourne Shell: How to concatenate variables that need to be evaluated?

蓝咒 提交于 2020-01-05 07:11:38
问题 I'm having trouble figuring out a way to properly concatenate several variables together. The idea is to collect several items over time (in this case "foo", "bar", and "baz") and then concatenate together into one string (ex: X = "foo bar baz"). The following is the code I have put together so far: #!/bin/sh N=0 # assign foo eval "DATA${N}='foo'" eval "echo First value is: \$DATA$N" # First value is: foo N=`expr $N + 1` # assign bar eval "DATA${N}='bar'" eval "echo Next value is: \$DATA$N" #

Why is if [ $? -eq 0 ] an antipattern? [duplicate]

蹲街弑〆低调 提交于 2020-01-05 07:00:00
问题 This question already has an answer here : Why is testing “$?” to see if a command succeeded or not, an anti-pattern? (1 answer) Closed 7 months ago . I see this pattern in a lot of shell scripts, including instruction books, tutorials, and production scripts from large and well-established vendors. command if [ $? -eq 0 ]; then things fi And yet I was told this is an antipattern. Why is that? What should I use instead? 回答1: Shell scripts are often written by people who are not very familiar

if-else on arguments in npm run script

荒凉一梦 提交于 2020-01-04 02:50:32
问题 I would like to call different other scripts, depending on whether a paramter is given or not: "paramtest": "if [ -z $1 ]; then echo Foo $1; else echo Bar; fi", npm run paramtest should give "Bar". npm run paramtest -- whatever should give "Foo whatever". However in practice I only get: (The parameter is added to the whole line, not 'passed in') > if [ -z $1 ]; then echo Foo; else echo Bar; fi "whatever sh: 1: Syntax error: word unexpected What can I do better? Essentially I am after running

Bash parse docker status to check if local image is up to date

杀马特。学长 韩版系。学妹 提交于 2020-01-04 02:19:10
问题 I have a starting docker script here: #!/usr/bin/env bash set -e echo '>>> Get old container id' CID=$(sudo docker ps --all | grep "web-client" | awk '{print $1}') echo $CID echo '>>> Stopping and deleting old container' if [ "$CID" != "" ]; then sudo docker stop $CID sudo docker rm $CID fi echo '>>> Starting new container' sudo docker pull my-example-registry.com:5050/web-client:latest sudo docker run --name=web-client -p 8080:80 -d my-example-registry.com:5050/web-client:latest The fact is

Gradle 'exit' in a shell script

女生的网名这么多〃 提交于 2020-01-03 19:17:19
问题 I want to build a package by Gradle (3.2.1) using a script. The script ( hoge.sh ) is #!/bin/sh gradle build echo "hello" ./hoge.sh works and prints "hello". However, cat hoge.sh | /bin/sh -s stops at gradle build . The build looks successful but the process never prints "hello". How can I fix hoge.sh to run by cat hoge.sh | /bin/sh -s correctly?? If I run cat hoge.sh | /bin/sh -i , it returns, sh-4.2$ #!/bin/sh sh-4.2$ gradle build ###gradle information### sh-4.2$ exit For information, using

How to read in arguments passed via ant to testng.xml

六眼飞鱼酱① 提交于 2020-01-03 05:33:08
问题 Here is the scenario: Have a shell script that calls ant with one argument. The ant in turn executes testng.xml (suite file) passing the same argument and testng in turn executes the test within passing the same argument. In my case, I am passing the browser string eg.(firefox, iexplore) argument that will specify which browser test will run on. I want to be able to have my test result output tell me which browser the test run in. I grab the argument from command line in ant by so: ...

How do I indirectly assign a variable in bash to take multi-line data from both Standard In, a File, and the output of execution

↘锁芯ラ 提交于 2020-01-03 04:43:27
问题 I have found many snippets here and in other places that answer parts of this question. I have even managed to do this in many steps in an inefficient manner. If it is possible, I would really like to find single lines of execution that will perform this task , rather than having to assign to a variable and copy it a few times to perform the task. e.g. executeToVar () { # Takes Arg1: NAME OF VARIABLE TO STORE IN # All Remaining Arguments Are Executed local STORE_INvar="${1}" ; shift eval $

Git cli not terminating on pull --rebase

自作多情 提交于 2020-01-03 03:25:13
问题 I am running Git v2.15.1.2 on a 64-bit machine. Whenever I try executing $ git pull -r to pull the latest update of my GitHub repo, this will happen: 1) The pull is successful, but it never returns to the line where I can type. 2) No matter how long I wait, it just bails out into a sh.exe.stackdump file. I tried reinstalling numerous times Git without any difference, and it works perfectly fine on my other computers. Do you guys know any way to fix this? 回答1: This was seen in git-for-windows