shell

How to extract ppl of this custom program?

痞子三分冷 提交于 2021-02-05 08:53:06
问题 I have a program that when I run, it prints something like this in command line: file test.test: 427 sentences, 2433 words, 1186 OOVs 0 zeroprobs, logprob= -4914.55 ppl= 862.603 ppl1= 8731.65 But I only want to save the number 862.603 in an environment variable. How can I extract that single number from output of the program? 回答1: Every answer I've seen thus far has had some deficiency, so I guess I'll go ahead and add this to the mix: There are a couple of ways to do this. My preferred way

Can't give metadata of comment to MP3 file using ffmpeg

拥有回忆 提交于 2021-02-05 08:47:26
问题 I want to covert a AAC to MP3 and give metadata of comment to the MP3 file using ffmpeg. But -metadata comment doesn't work and ffmpeg doesn't return any error. My code is ffmpeg -i "test.aac" -ab 128k -metadata comment='this is test' "test.mp3" I tried -metadata description='this is test' and also update ffmpeg. Other function such as -metadata artist and -metadata album works well. What's wrong with this code? Output Stream mapping: Stream #0:0 -> #0:0 (aac (native) -> mp3 (libmp3lame))

How to run multiple curl requests in parallel with multiple variables

瘦欲@ 提交于 2021-02-05 08:44:38
问题 Set Up I currently have the below script working to download files with curl , using a ref file with multiple variables. When I created the script it suited my needs however as the ref file has gotten larger and the data I am requesting via curl is takes longer to generate, my script is now taking too much time to complete. Objective I want to be able to update this script so I have curl request and download multiple files as they are ready - as opposed to waiting for each file to be

How to run multiple curl requests in parallel with multiple variables

落花浮王杯 提交于 2021-02-05 08:44:26
问题 Set Up I currently have the below script working to download files with curl , using a ref file with multiple variables. When I created the script it suited my needs however as the ref file has gotten larger and the data I am requesting via curl is takes longer to generate, my script is now taking too much time to complete. Objective I want to be able to update this script so I have curl request and download multiple files as they are ready - as opposed to waiting for each file to be

How to find out which font can display these characters?

拥有回忆 提交于 2021-02-05 08:32:15
问题 ⚫⚪ Unicode U+26AB Unicode U+26AA This two characters can be display in terminal, I want use convert (imagemagick command) to convert those text into picture. But convert only can use one special font , not fallback font could be used. convert -list font So how can I find which font could display those characters? 回答1: I adapted the code in this answer, to make a script to find which font contains a particular character as follows: #!/usr/bin/env python3 import os, sys import unicodedata from

How to find out which font can display these characters?

烈酒焚心 提交于 2021-02-05 08:32:04
问题 ⚫⚪ Unicode U+26AB Unicode U+26AA This two characters can be display in terminal, I want use convert (imagemagick command) to convert those text into picture. But convert only can use one special font , not fallback font could be used. convert -list font So how can I find which font could display those characters? 回答1: I adapted the code in this answer, to make a script to find which font contains a particular character as follows: #!/usr/bin/env python3 import os, sys import unicodedata from

Permission denied on cat via shell script [duplicate]

一个人想着一个人 提交于 2021-02-05 08:18:58
问题 This question already has answers here : How do I set a variable to the output of a command in Bash? (14 answers) Closed 4 years ago . I have an issue with running cat in shell script on a log file which is in ~/bin/rclone_sync_ACD.log. This is the line in the shell script: RESULT=cat $LOGFILE | tail -1 But when running the script I get: ./rclone_sync: line 63: /Users/pjburnhill/bin/rclone_sync_ACD.log: Permission denied In terminal, if I type cat $LOGFILE | tail -1 , it gives the right

Permission denied on cat via shell script [duplicate]

点点圈 提交于 2021-02-05 08:18:06
问题 This question already has answers here : How do I set a variable to the output of a command in Bash? (14 answers) Closed 4 years ago . I have an issue with running cat in shell script on a log file which is in ~/bin/rclone_sync_ACD.log. This is the line in the shell script: RESULT=cat $LOGFILE | tail -1 But when running the script I get: ./rclone_sync: line 63: /Users/pjburnhill/bin/rclone_sync_ACD.log: Permission denied In terminal, if I type cat $LOGFILE | tail -1 , it gives the right

How to search and replace the specific line number string

落爺英雄遲暮 提交于 2021-02-05 08:17:45
问题 line_index="2d"; file="./Desktop/books.sh"; sed -i.bak -e $line_index $file Will delete the entire line that $line_index is pointing to sed -i "s/harry/potter/g" $file will search for harry and replace with potter Is there anyway that i can combine both statement so it will only replace the specific line number of harry instead of all the harry in the file. 回答1: Sure, "addresses" and "commands" can be freely combined: sed '2s/harry/potter/g' 回答2: To restrict substitution to a line number, add

macOS Mojave version 10.14.1 bash-3.2 expr: syntax error

こ雲淡風輕ζ 提交于 2021-02-05 08:13:29
问题 I meet such error: expr: syntax error and my script is: #!/bin/bash echo `expr index "sarasara" a` how to fix it. 回答1: $ man expr gives this at the end: According to the POSIX standard, the use of string arguments length , substr , index , or match produces undefined results. In this version of expr , these arguments are treated just as their respective string values. In other words, macOS' expr does not support index . 来源: https://stackoverflow.com/questions/53701873/macos-mojave-version-10