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

15 managing disk - understanding /etc/fstab xfs_admin mount -o rw,remount /