xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

Linux shell script shebang env All In One

Linux shell script shebang env All In One

指定 shell script 的运行环境

shell script shebang env

hash bang env

#!\usr\bin\env bash

#!\usr\bin\env bash
# ❌

#!/usr/bin/env

#!/usr/bin/env bash
✅

demos

image

image

#!/usr/bin/env bash
# ✅

export N=1
# case 1 数字
# suceess exit ✅

# ✅
case "$N" in
  1)
    echo 'case 1 数字';;
  2)
    echo 'case 2 数字';;
  *)
    echo 'default case 数字 *'
    echo 'error exit ❌'
    exit 1
  ;;
esac

echo 'suceess exit ✅'
exit 0

(🐞 反爬虫测试!打击盗版⚠️)如果你看到这个信息, 说明这是一篇剽窃的文章,请访问 https://www.cnblogs.com/xgqfrms/ 查看原创文章!

#!/usr/bin/env bash vs #!/usr/bin/bash vs #!/bin/bash

The Difference Between #!/bin/bash and #!/usr/bin/env bash

The Difference Between #!/usr/bin/bash and #!/usr/bin/env bash

https://www.baeldung.com/linux/bash-shebang-lines

https://unix.stackexchange.com/questions/29608/why-is-it-better-to-use-usr-bin-env-name-instead-of-path-to-name-as-my

https://stackoverflow.com/questions/16365130/what-is-the-difference-between-usr-bin-env-bash-and-usr-bin-bash

refs

https://www.cyberciti.biz/tips/finding-bash-perl-python-portably-using-env.html

https://stackoverflow.com/questions/43793040/how-does-usr-bin-env-work-in-a-linux-shebang-line

https://www.baeldung.com/linux/bash-shebang-lines

https://unix.stackexchange.com/questions/29608/why-is-it-better-to-use-usr-bin-env-name-instead-of-path-to-name-as-my

https://stackoverflow.com/questions/16365130/what-is-the-difference-between-usr-bin-env-bash-and-usr-bin-bash



©xgqfrms 2012-2021

www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!

原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!


posted @ 2023-05-03 16:06  xgqfrms  阅读(16)  评论(1编辑  收藏  举报