0

I have this simple bash command which purpose is store the line, modified by sed into a variable

unset x
while read line; do
echo $line'_db'|sed 's/- //g' | read x
echo $x
done < <(yq eval '.databases' ${databasesPath});

So far I have this, text file contains the line "- name"

for some reason when I execute the above, and echo I get a blank line, as if nothing get stored into the variable? Whag am doing wrong.

Beside the variable only need to exist within the scope of the while loop, and not outside, do need to declare it outside?

Why? The modified has to parsed into a command within the same while loop, but cannot be parsed as it is read.

I am not Fat
  • 283
  • 11
  • 36
  • https://unix.stackexchange.com/questions/338000/bash-assign-output-of-pipe-to-a-variable check your scripts with https://shellcheck.net – KamilCuk May 26 '21 at 11:43
  • 1
    [`read x < <(echo ...)`](https://stackoverflow.com/a/37886601/10248678) should do it. – oguz ismail May 26 '21 at 11:46

0 Answers0