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 ~]#
#!/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
Post a Comment