Check wget’s return value

Others have correctly posted that you can use $? to get the most recent exit code: wget_output=$(wget -q “$URL”) if [ $? -ne 0 ]; then … This lets you capture both the stdout and the exit code. If you don’t actually care what it prints, you can just test it directly: if wget -q … Read more

Should I use a Shebang with Bash scripts?

On UNIX-like systems, you should always start scripts with a shebang line. The system call execve (which is responsible for starting programs) relies on an executable having either an executable header or a shebang line. From FreeBSD’s execve manual page: The execve() system call transforms the calling process into a new process. The new process … Read more