shebang

How to use multiple arguments for awk with a shebang (i.e. #!)?

家住魔仙堡 提交于 2019-11-25 23:54:00
问题 I\'d like to execute an gawk script with --re-interval using a shebang. The \"naive\" approach of #!/usr/bin/gawk --re-interval -f ... awk script goes here does not work, since gawk is called with the first argument \"--re-interval -f\" (not splitted around the whitespace), which it does not understand. Is there a workaround for that? Of course you can either not call gawk directly but wrap it into a shell script that splits the first argument, or make a shell script that then calls gawk and

What is the preferred Bash shebang?

◇◆丶佛笑我妖孽 提交于 2019-11-25 23:02:27
Is there any Bash shebang objectively better than the others for most uses? #!/usr/bin/env bash #!/bin/bash #!/bin/sh #!/bin/sh - etc I vaguely recall a long time ago hearing that adding a dash to the end prevents someone passing a command to your script, but can’t find any details on that. You should use #!/usr/bin/env bash for portability : different *nixes put bash in different places, and using /usr/bin/env is a workaround to run the first bash found on the PATH . And sh is not bash . /bin/sh is usually a link to the system's default shell, which is often bash but on, e.g., Debian systems

Why do people write the #!/usr/bin/env python shebang on the first line of a Python script?

╄→尐↘猪︶ㄣ 提交于 2019-11-25 22:56:25
问题 It seems to me like the files run the same without that line. 回答1: If you have several versions of Python installed, /usr/bin/env will ensure the interpreter used is the first one on your environment's $PATH . The alternative would be to hardcode something like #!/usr/bin/python ; that's ok, but less flexible. In Unix, an executable file that's meant to be interpreted can indicate what interpreter to use by having a #! at the start of the first line, followed by the interpreter (and any flags