Skip to main content
Add oguzismail's comment.
Source Link
Mark
  • 4.5k
  • 1
  • 22
  • 28

foo is in scope in your program, but it is empty.
Consider this code:

foo="test"
while read foo; do echo $foo; done < /dev/null
echo "foo=$foo"

The result is:

foo=

The problem is that foo will be set to empty when read has no input. That's what's happening in your program.

That said, pay attention to oguzismail's comment. (S)he is leading you a good direction:

paste FooFile BarFile | xargs -n 2 ./dothis.sh

It's really an excellent start and probably all you'll need in the simple cases where FooFile and BarFile have the same amount of entries.

foo is in scope in your program, but it is empty.
Consider this code:

foo="test"
while read foo; do echo $foo; done < /dev/null
echo "foo=$foo"

The result is:

foo=

The problem is that foo will be set to empty when read has no input. That's what's happening in your program.

foo is in scope in your program, but it is empty.
Consider this code:

foo="test"
while read foo; do echo $foo; done < /dev/null
echo "foo=$foo"

The result is:

foo=

The problem is that foo will be set to empty when read has no input. That's what's happening in your program.

That said, pay attention to oguzismail's comment. (S)he is leading you a good direction:

paste FooFile BarFile | xargs -n 2 ./dothis.sh

It's really an excellent start and probably all you'll need in the simple cases where FooFile and BarFile have the same amount of entries.

Source Link
Mark
  • 4.5k
  • 1
  • 22
  • 28

foo is in scope in your program, but it is empty.
Consider this code:

foo="test"
while read foo; do echo $foo; done < /dev/null
echo "foo=$foo"

The result is:

foo=

The problem is that foo will be set to empty when read has no input. That's what's happening in your program.