bash

How to make .avi, .mp4 file with jpeg frames?

痴心易碎 提交于 2021-02-05 06:43:11
问题 I'm working with IP camera, and I have got Jpeg frames and audio data (PCM) from camera. Now, I want to create video file (both audio and video) under .avi or .mp4 format from above data. I searched and I knew that ffmpeg library can do it. But I don't know how to using ffmpeg to do this. Can you suggest me some sample code or the function of ffmpeg to do it? 回答1: If your objective is to write a c++ app to do this for you please disregard this answer, I'll just leave it here for future

Bash -eq and ==, what's the diff?

浪尽此生 提交于 2021-02-05 06:37:32
问题 Why this works: Output=$( tail --lines=1 $fileDiProva ) ##[INFO]Output = "OK" if [[ $Output == $OK ]]; then echo "OK" else echo "No Match" fi and this not? Output=$( tail --lines=1 $fileDiProva ) ##[INFO]Output = "OK" if [[ $Output -eq $OK ]]; then echo "OK" else echo "No Match" fi What's the difference?? between == and -eq? Thanks! 回答1: -eq is an arithmetic test. You are comparing strings. From help test : Other operators: arg1 OP arg2 Arithmetic tests. OP is one of -eq, -ne, -lt, -le, -gt,

How to move first column to last column in unix?

淺唱寂寞╮ 提交于 2021-02-05 06:37:26
问题 This is the data in a text file. 0.354167 male atyp_angina 0.066038 0.1621 t normal 0.648855 no 0 up 0 reversable_defect <50 0.625 male typ_angina 0.792453 0.328767 f left_vent_hyper 0.564885 no 0.677419 down 0 reversable_defect <50 0.645833 male non_anginal 0.433962 0.134703 f left_vent_hyper 0.641221 no 0.483871 flat 0 normal >50_1 0.666667 female asympt 0.481132 0.413242 f left_vent_hyper 0.572519 yes 0.16129 flat 0 reversable_defect >50_1 0.270833 male typ_angina 0.509434 0.269406 f left

Shell script: open multiple terminals and run commands?

帅比萌擦擦* 提交于 2021-02-05 06:31:12
问题 I'm trying to create a very simple shell script that opens and runs five instances of my program. With batch, I would do something like this: @echo off python webstore.py 55530 python webstore.py 55531 python webstore.py 55532 exit That would open three terminals and run the commands on each of them with different command line parameter. How would I create the same with a shell script that runs on every single unix-based platform? I've seen some commands for opening terminals, but they are

Shell script: open multiple terminals and run commands?

拥有回忆 提交于 2021-02-05 06:31:10
问题 I'm trying to create a very simple shell script that opens and runs five instances of my program. With batch, I would do something like this: @echo off python webstore.py 55530 python webstore.py 55531 python webstore.py 55532 exit That would open three terminals and run the commands on each of them with different command line parameter. How would I create the same with a shell script that runs on every single unix-based platform? I've seen some commands for opening terminals, but they are

Is there a way to avoid “newline in string” errors in awk?

China☆狼群 提交于 2021-02-05 06:21:50
问题 How are cmdline args containing newline chars passed to awk ? See two examples below: awk -v s='text' 'BEGIN { print(s) }' text awk -v s=$'\n''text' 'BEGIN { print(s) }' awk: newline in string text... at source line 1 回答1: What you have would work as-is with gawk. With OSX (BSD) awk like you're using, either don't put a linefeed character in the string. $ awk -v s='\ntext' 'BEGIN{ print s }' text or escape it: awk -v s='\ text' 'BEGIN{ print s }' text or (portably with any awk) don't pass it

Is there a way to avoid “newline in string” errors in awk?

六眼飞鱼酱① 提交于 2021-02-05 06:21:48
问题 How are cmdline args containing newline chars passed to awk ? See two examples below: awk -v s='text' 'BEGIN { print(s) }' text awk -v s=$'\n''text' 'BEGIN { print(s) }' awk: newline in string text... at source line 1 回答1: What you have would work as-is with gawk. With OSX (BSD) awk like you're using, either don't put a linefeed character in the string. $ awk -v s='\ntext' 'BEGIN{ print s }' text or escape it: awk -v s='\ text' 'BEGIN{ print s }' text or (portably with any awk) don't pass it

coloring in heredocs, bash

◇◆丶佛笑我妖孽 提交于 2021-02-05 06:21:11
问题 If I have previously defined color variable like this: txtred='\e[1;31m' How would I use it in heredoc : cat << EOM [colorcode here] USAGE: EOM I mean what should I write in place of [colorcode here] to render that USAGE text red? ${txtred} won't work, as that is what I am using throughout my bash script, outside of heredoc 回答1: You need something to interpret the escape sequence which cat won't do. This is why you need echo -e instead of just echo to make it work normally. cat << EOM $(echo

Validate the number of arguments passed in bash from read

China☆狼群 提交于 2021-02-05 06:09:51
问题 I have a question about validating user input regarding number of arguments passed by the user in a bash script. For example, if I use: if [[ $# -eq 2 ]] then... that will check if 2 arguments passed from the command line like this: ./somescript.sh arg1 arg2 but how to validate if user passed 2 arguments when asked? For example: echo "Type 2 names:" read... if [[ user passed more || less than 2 arguments]] echo "incorrect number of names" Now if I try to use $# -eq 2 it doesn't work. What's

Validate the number of arguments passed in bash from read

半腔热情 提交于 2021-02-05 06:06:18
问题 I have a question about validating user input regarding number of arguments passed by the user in a bash script. For example, if I use: if [[ $# -eq 2 ]] then... that will check if 2 arguments passed from the command line like this: ./somescript.sh arg1 arg2 but how to validate if user passed 2 arguments when asked? For example: echo "Type 2 names:" read... if [[ user passed more || less than 2 arguments]] echo "incorrect number of names" Now if I try to use $# -eq 2 it doesn't work. What's