Bash scripting missing ']'

bash, scripting

Solution

Change

if [ -s "p1"];  #line 13

into

if [ -s "p1" ];  #line 13

note the space.

Problem

I am getting an error ./test.sh: line 13: [: missing `]' in the file test.sh I tried using brackets and other options such as -a or by checking the size of the file p1 but the error is always there and the else statement is always executed irrespective of the input given.I even tried by removing the ; in line 13 but it didn't help. test.sh ``` #!/bin/bash echo "Enter app name" read y $y & top -b -n 1 > topLog.log #-w checks for the whole word not and sub string from that word grep -w "$y" topLog.log > p1 #-s option checks if the file p1 is present or not if [ -s "p1"]; #line 13 then echo "Successful " else echo "Unsuccessful" fi rm p1 ``` I am new to bash scripting.So if there is any silly mistake please excuse me.

Original source