0

I have created a file with the name pingscript.sh in Kali Linux included the below codes:

#!/bin/bash

if ["$1"==""]
then
    echo "usage: ./pingscrpt.sh [Network]"
    echo "usage: ./pingscrpt.sh 192.168.1"
else
    for x in `seq 1 254`; do
        ping -c 1 $1.$x | grep "64 bytes"
    done
fi

but when running it with ./pingscript.sh, I face the below error:

./pingscript.sh: line 3: [==]: command not found

What can be the problem?

Amir
  • 1
  • 1
  • 1
    Copy paste your script in [ShellCheck](https://www.shellcheck.net/) to fix the syntax errors shown – Inian Jan 29 '18 at 07:51
  • see my answer @ https://stackoverflow.com/questions/47809065/why-1-2-evaluates-to-true/47809177#47809177 – Allan Jan 29 '18 at 08:38

1 Answers1

3

Spaces missed in:

if ["$1"==""]

should be

if [ "$1" == "" ]
0xAX
  • 20,957
  • 26
  • 117
  • 206