Issue
I want to automate the compilation of GO lang. I have shell script
for i in *.go
do
echo "go build -o ${i%.*} $i"
done
but this is just printing out the output but not executing.
Output: ./c.sh
go build -o binarytrees binarytrees.go
go build -o fannkuch fannkuch.go
go build -o fasta.go-2 fasta.go-2.go
but it does not actually execute these commands.
Solution
echo commands doesn't execute the statements rather they just print the expression written under ""
.
To complete the build you would do something like this
for i in *.go
do
echo "go build -o ${i%.*} $i"
go build -o ${i%.*} $i
done
Or you can even pipe your command into shell by echo "go build x y" | bash -
Answered By - Kush Trivedi