Bash 模糊重定向

Bash 模糊重定向,bash,slurm,Bash,Slurm,我不确定我的slurm脚本有什么问题-我收到的错误消息是$input的不明确重定向,在我试图定义变量时找不到命令 #!/bin/bash #SBATCH --job-name=gim #SBATCH --time=24:00:00 #SBATCH --ntasks=20 #SBATCH --ntasks-per-node=2 #SBATCH --cpus-per-task=1 #SBATCH -o output_%A_%a.out #Standard Output #SBATCH -e outp

我不确定我的slurm脚本有什么问题-我收到的错误消息是$input的不明确重定向,在我试图定义变量时找不到命令

#!/bin/bash
#SBATCH --job-name=gim
#SBATCH --time=24:00:00
#SBATCH --ntasks=20
#SBATCH --ntasks-per-node=2
#SBATCH --cpus-per-task=1
#SBATCH -o output_%A_%a.out #Standard Output
#SBATCH -e output_%A_%a.err #Standard Error

module load program

input= gim${SLURM_ARRAY_TASK_ID}.gjf
output= gim${SLURM_ARRAY_TASK_ID}.log

program $input > $output
我运行它的方式是:

sbatch --array=1-500 ./slurm.job
空格问题:

#!/bin/bash
# ...etc...

input=gim${SLURM_ARRAY_TASK_ID}.gjf
output=gim${SLURM_ARRAY_TASK_ID}.log

program "$input" > "$output"
foo = bar # this runs "foo" with "=" as the first argument and "bar" as the second
foo =bar  # this runs "foo" with "=bar" as its first argument
foo= bar  # this runs "bar" as a command with "foo" as an empty string in its environment
foo=bar   # this assigns the value "bar" to the shell variable "foo"
注意分配的
=
符号周围缺少空格。空格问题:

#!/bin/bash
# ...etc...

input=gim${SLURM_ARRAY_TASK_ID}.gjf
output=gim${SLURM_ARRAY_TASK_ID}.log

program "$input" > "$output"
foo = bar # this runs "foo" with "=" as the first argument and "bar" as the second
foo =bar  # this runs "foo" with "=bar" as its first argument
foo= bar  # this runs "bar" as a command with "foo" as an empty string in its environment
foo=bar   # this assigns the value "bar" to the shell variable "foo"
空格问题:

#!/bin/bash
# ...etc...

input=gim${SLURM_ARRAY_TASK_ID}.gjf
output=gim${SLURM_ARRAY_TASK_ID}.log

program "$input" > "$output"
foo = bar # this runs "foo" with "=" as the first argument and "bar" as the second
foo =bar  # this runs "foo" with "=bar" as its first argument
foo= bar  # this runs "bar" as a command with "foo" as an empty string in its environment
foo=bar   # this assigns the value "bar" to the shell variable "foo"
注意分配的
=
符号周围缺少空格。空格问题:

#!/bin/bash
# ...etc...

input=gim${SLURM_ARRAY_TASK_ID}.gjf
output=gim${SLURM_ARRAY_TASK_ID}.log

program "$input" > "$output"
foo = bar # this runs "foo" with "=" as the first argument and "bar" as the second
foo =bar  # this runs "foo" with "=bar" as its first argument
foo= bar  # this runs "bar" as a command with "foo" as an empty string in its environment
foo=bar   # this assigns the value "bar" to the shell variable "foo"

input=foo
作为一个命令运行
foo
,该命令的
input
设置为一个环境变量,仅在该单次执行期间具有空值。
input=foo
作为一个命令运行
foo
作为一个环境变量,在执行期间具有空值只有一个执行。谢谢,另一个教训:BTW,考虑使用习惯(也是一个可安装的工具),这将自动识别这类错误(和其他)。谢谢,另一个教训:BTW,考虑养成使用习惯(也可安装工具),这将识别这一类错误(和其他)。自动地