小编Rob*_*lot的帖子

检查音频文件是否有效,如shell中的MP3

我正在编写一个Bash Shell脚本,需要确定提供的MP3音频文件是有效还是无效.我将如何在Bash中实现这一目标?

例如假的​​:> file.mp3mv file.txt file.mp3

bash shell

5
推荐指数
1
解决办法
1559
查看次数

字符串来源?shell有什么办法吗?

例:

#!/bin/bash
source "$VARIABLE"
Run Code Online (Sandbox Code Playgroud)

是使用curl从远程位置检索值.

http://example.com/file.cnfg
Run Code Online (Sandbox Code Playgroud)

bash shell

4
推荐指数
2
解决办法
4182
查看次数

防止从Bash中的源文件执行命令

为了安全起见,如何防止在source'd' 文件中执行命令?例如:

#!/bin/sh
source file.cfg
Run Code Online (Sandbox Code Playgroud)

通缉:

get="value"
Run Code Online (Sandbox Code Playgroud)

意外的:

command
Run Code Online (Sandbox Code Playgroud)

bash shell

2
推荐指数
2
解决办法
2163
查看次数

如何在Bash中运行子函数

如何在命令行中从脚本运行"子功能"?例:

#script_1.sh
main_function() {
    sub_function() {
         echo "hello world"
    }
}
Run Code Online (Sandbox Code Playgroud)

我试图获取此文件并从另一个脚本调用该函数:

#script_2.sh
source script_1.sh

sub_function
Run Code Online (Sandbox Code Playgroud)

但我明白了

script_2.sh: line 3: sub_function: command not found
Run Code Online (Sandbox Code Playgroud)

虽然我期望得到hello world.

bash shell

1
推荐指数
1
解决办法
2169
查看次数

标签 统计

bash ×4

shell ×4