unix

While loop in bash to read a file skips first 2 characters of THIRD Line

荒凉一梦 提交于 2021-02-08 08:14:11
问题 #bin/bash INPUT_DIR="$1" INPUT_VIDEO="$2" OUTPUT_PATH="$3" SOURCE="$4" DATE="$5" INPUT="$INPUT_DIR/sorted_result.txt" COUNT=1 initial=00:00:00 while IFS= read -r line; do OUT_DIR=$OUTPUT_PATH/$COUNT mkdir "$OUT_DIR" ffmpeg -nostdin -i $INPUT_VIDEO -vcodec h264 -vf fps=25 -ss $initial -to $line $OUT_DIR/$COUNT.avi ffmpeg -i $OUT_DIR/$COUNT.avi -acodec pcm_s16le -ar 16000 -ac 1 $OUT_DIR/$COUNT.wav python3.6 /home/Video_Audio_Chunks_1.py $OUT_DIR/$COUNT.wav python /home/transcribe.py --decoder

While loop in bash to read a file skips first 2 characters of THIRD Line

﹥>﹥吖頭↗ 提交于 2021-02-08 08:14:09
问题 #bin/bash INPUT_DIR="$1" INPUT_VIDEO="$2" OUTPUT_PATH="$3" SOURCE="$4" DATE="$5" INPUT="$INPUT_DIR/sorted_result.txt" COUNT=1 initial=00:00:00 while IFS= read -r line; do OUT_DIR=$OUTPUT_PATH/$COUNT mkdir "$OUT_DIR" ffmpeg -nostdin -i $INPUT_VIDEO -vcodec h264 -vf fps=25 -ss $initial -to $line $OUT_DIR/$COUNT.avi ffmpeg -i $OUT_DIR/$COUNT.avi -acodec pcm_s16le -ar 16000 -ac 1 $OUT_DIR/$COUNT.wav python3.6 /home/Video_Audio_Chunks_1.py $OUT_DIR/$COUNT.wav python /home/transcribe.py --decoder

Create bins with awk histogram-like

浪子不回头ぞ 提交于 2021-02-08 07:51:17
问题 Here's my input file : 1.37987 1.21448 0.624999 1.28966 1.77084 1.088 1.41667 I would like to create bins of a size of my choice to get histogram-like output, e.g. something like this for 0.1 bins, starting from 0 : 0 0.1 0 ... 0.5 0.6 0 0.6 0.7 1 ... 1.0 1.1 1 1.1 1.2 0 1.2 1.3 2 1.3 1.4 1 ... My file is too big for R, so I'm looking for an awk solution (also open to anything else that I can understand, as I'm still a Linux beginner). This was sort of already answered in this post : awk

Long lines overlap in Bash PS1 prompt

本秂侑毒 提交于 2021-02-08 07:47:04
问题 I have configured a PS1 bash prompt. My ~/.bashrc file: if [[ $EUID -ne 0 ]]; then PS1='\n\e[0;33m☛ \W\e[0m \n\e[1;35m⤷\e[0m ' fi The problem is that the new line overlaps the previous one. Any idea how to fix this? 回答1: When using non-printing characters in a bash prompt, you have to specify non-printing sequences (e.g. color codes) as non-printing, using \[...\] : PS1='\n\[\e[0;33m\]☛ \W\[\e[0m\] \n\[\e[1;35m\]⤷\[\e[0m\] ' 来源: https://stackoverflow.com/questions/17306348/long-lines-overlap

Long lines overlap in Bash PS1 prompt

南笙酒味 提交于 2021-02-08 07:45:51
问题 I have configured a PS1 bash prompt. My ~/.bashrc file: if [[ $EUID -ne 0 ]]; then PS1='\n\e[0;33m☛ \W\e[0m \n\e[1;35m⤷\e[0m ' fi The problem is that the new line overlaps the previous one. Any idea how to fix this? 回答1: When using non-printing characters in a bash prompt, you have to specify non-printing sequences (e.g. color codes) as non-printing, using \[...\] : PS1='\n\[\e[0;33m\]☛ \W\[\e[0m\] \n\[\e[1;35m\]⤷\[\e[0m\] ' 来源: https://stackoverflow.com/questions/17306348/long-lines-overlap

how to automatically write curl output to a new file

末鹿安然 提交于 2021-02-08 07:43:22
问题 I am using cURL to retrieve stock information back to the terminal window on my Mac using the yahoo finance api. i.e. I type: curl -s 'http://download.finance.yahoo.com/d/quotes.csv?s=aapl&f=l1' and it prints the output (in this instance the last trade price in the command line) It works terrific, but I would like to know how to get this output automatically written to a stock.txt file located on my desktop without any manual intervention upon the execution of the original cURL command. Thus

Roundup function in Unix

元气小坏坏 提交于 2021-02-08 03:49:26
问题 I have a requirement as below 121.36 121.025 121.1 121.000 Desired output 122 122 122 121 Command used awk -F"." '{if($8>0){print $11}}' 回答1: What you're asking for is a ceil() (for "ceiling") function. It's important to include zero and negative numbers in your example when you're looking for any kind of rounding function as it's easy to get them wrong so using this input file: $ cat file 1.999999 1.0 0.000001 0 -0.000001 -1.0 -1.999999 we can test a ceil() function: $ awk 'function ceil(x,

Roundup function in Unix

≡放荡痞女 提交于 2021-02-08 03:49:03
问题 I have a requirement as below 121.36 121.025 121.1 121.000 Desired output 122 122 122 121 Command used awk -F"." '{if($8>0){print $11}}' 回答1: What you're asking for is a ceil() (for "ceiling") function. It's important to include zero and negative numbers in your example when you're looking for any kind of rounding function as it's easy to get them wrong so using this input file: $ cat file 1.999999 1.0 0.000001 0 -0.000001 -1.0 -1.999999 we can test a ceil() function: $ awk 'function ceil(x,

Split audio file into several files, each below a size threshold

时光总嘲笑我的痴心妄想 提交于 2021-02-07 20:45:59
问题 I have a FLAC file which I need to split into several distinct FLAC files, each of which must be below 100 MB in size. Are there any UNIX tools which can do this for me? Can I implement this logic myself? Side-note: since FLAC is compressed, I figure that the easiest solution will require first converting the file to WAV. 回答1: There are two parts to your question. Convert existing FLAC audio file to some other format like wav Split converted wav file into chunk of specific size. Obviously,

Split audio file into several files, each below a size threshold

喜夏-厌秋 提交于 2021-02-07 20:45:25
问题 I have a FLAC file which I need to split into several distinct FLAC files, each of which must be below 100 MB in size. Are there any UNIX tools which can do this for me? Can I implement this logic myself? Side-note: since FLAC is compressed, I figure that the easiest solution will require first converting the file to WAV. 回答1: There are two parts to your question. Convert existing FLAC audio file to some other format like wav Split converted wav file into chunk of specific size. Obviously,