Command not found bash

Asked

Viewed 414 times

0

I am encountered the following error while running this script:

line 7: [1: command not found

#!/bin/bash


#$ for counter in $(seq 1 255); do curl -X POST -H 'Content-Type: application/json' http://127.0.0.1:5000/api/echo-json -d '[{"id": "123", "name": "oi"}]'; done
for counter in $(seq 1 600)
do
    if ["$counter" == 2]; then
        echo oi
        curl -X POST -H 'Content-Type: application/json' http://127.0.0.1:5000/api/echo-json -d '[{"id": "123", "name": '"$counter"'}]'
    fi
    curl -X POST -H 'Content-Type: application/json' http://127.0.0.1:5000/api/echo-json -d '[{"id": "123", "name":'"$counter"'}]'

sleep 1
done
  • 1
    1. sudo apt-get update 2) sudo apt-get install curl
  • 1

    I have already installed, I think the problem is in if, because echo hi ta not appearing tbm

  • hi wouldn’t have to be in quotes?

  • I put it and it didn’t help

1 answer

3


All right?!

Try to run the "if" exactly as follows:

   if [ $counter == '2' ]; then
    echo "oi"
   fi

I did a test from here and it worked. Follow:

inserir a descrição da imagem aqui

I hope I helped. Hugs!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.