What’s the difference betwen the single dash and double dash flags on shell commands?

A single hyphen can be followed by multiple single-character flags. A double hyphen prefixes a single, multicharacter option. Consider this example: tar -czf In this example, -czf specifies three single-character flags: c, z, and f. Now consider another example: tar –exclude In this case, –exclude specifies a single, multicharacter option named exclude. The double hyphen … Read more

What are the uses of the exec command in shell scripts? 

The exec built-in command mirrors functions in the kernel, there are a family of them based on execve, which is usually called from C. exec replaces the current program in the current process, without forking a new process. It is not something you would use in every script you write, but it comes in handy on occasion. Here are some … Read more

How to get a shell environment variable in a makefile?

If you’ve exported the environment variable: you can simply refer to it by name in the makefile (make imports all the environment variables you have set): If you’ve not exported the environment variable, it is not accessible until you do export it, or unless you pass it explicitly on the command line: If you are using a C … Read more

Block Comments in a Shell Script

In bash: The ‘ and ‘ around the END delimiter are important, otherwise things inside the block like for example $(command) will be parsed and executed. For an explanation, see this and this question.