-1

I tried to run the code as below and it gets me error: command not found for line 4,5,6. Tried to find similar answers for the questions but I don't know how to figure out the version of the OS of the cluster which Im running this script. Im not sure is there any problem with the first line or the line 4,5,6. Could anyone help?

#!/bin/bash
for i in 02 03 04 05 06 07 09 10 11 12 13 14 15 16 17 20 21 22 23 24 25; do
 x=grep $i sphnum.txt |cut -c5-6
 y=grep $i sphnum.txt |cut -c8-9
 z=echo $i'.ala.'$x'.sph '$i'.ala.'$y'.sph'
 echo $z
done
SIMONSON92
  • 73
  • 6

1 Answers1

0

As the others said you need to capture the output from the commands.

z=echo foo -bash: foo: command not found

is not the same as

z=$(echo foo)

In the first one it's equivalent to

z=echo foo

which is not valid as it thinks foo is a command.

z=$(echo foo) however means to execute echo foo and capture the output into z.

All of your commands fail to do this.

Marc Young
  • 3,854
  • 3
  • 18
  • 22