validate bash syntax bash -n script

[root@svn ~]# cat sc.sh
#!/bin/bash
while [ true ]
do; {
date >> file1
sleep 5
}
done


[root@svn ~]# bash -n sc.sh 
sc.sh: line 3: syntax error near unexpected token `;'
sc.sh: line 3: `do; {'
[root@svn ~]#

bash -n scriptname
Perhaps an obvious caveat: this validates syntax but won't check if your bash script tries to execute a command that isn't in your path, like ech hello instead of echo hello.

Comments

Popular posts from this blog

HAproxy logging

teamcity Automatic Agent Start under Linux

NFS mount add in fstab _netdev instead of default | firewall-cmd --list-all