1 year ago

#311414

test-img

Scripter

BASH - run concated variable with alias as command

I have an text-file script in #!/bin/bash, where I run concated variable CMD as command and it works in Csh, but not in Bash.

CMD="word${year} ${FILE_version.txt} > ${FILE_version.out} &"
(CMD='word'"$year"' '"$FILE_version.txt"' > '"$FILE_version.out"' &'

I also tried this second version of CMD variable, it didnt help)

  • word2018 - alias defined/sourced default from other location (single alias word2018 works OK in bash shell terminal)
  • word - static text name
  • 2018 - variable (can be any year number 2015, 2018, 2022,....)
  • FILE_version - variable (can be - FILE_2015, FILE_2018, FILE_2022,...)

The command

csh -c "$CMD"

works OK in a Bash shell terminal, but

bash -c "$CMD"

is NOT working in bash shell terminal, I get word2018 - command not found

bash

variables

command

csh

0 Answers

Your Answer

Accepted video resources