相关疑难解决方法(0)

sh和bash之间的区别

在编写shell程序时,我们经常使用/bin/sh/bin/bash.我经常使用bash,但我不知道它们之间有什么区别.

bash和之间的主要区别是sh什么?

我们究竟需要意识到在编程时bashsh

unix bash shell sh

1194
推荐指数
11
解决办法
46万
查看次数

为什么在可执行文件或脚本名称之前需要./(dot-slash)才能在bash中运行它?

在bash中运行脚本时,我必须./在开头写:

$ ./manage.py syncdb
Run Code Online (Sandbox Code Playgroud)

如果我不这样做,我收到一条错误消息:

$ manage.py syncdb
-bash: manage.py: command not found
Run Code Online (Sandbox Code Playgroud)

这是什么原因?我认为.是当前文件夹的别名,因此这两个调用应该是等效的.

我也不明白为什么我./在运行应用程序时不需要,例如:

user:/home/user$ cd /usr/bin
user:/usr/bin$ git
Run Code Online (Sandbox Code Playgroud)

(没有运行./)

unix bash shell command-line

272
推荐指数
4
解决办法
10万
查看次数

MacOS 更喜欢 /bin/sh 还是 /bin/bash?

我想与某人共享一个脚本,但不确定 MacOS 上首选哪个。哪一个最好支持?

这?

#!/bin/sh
echo "Here goes my simple script that changes some settings."
# ... do some stuff
Run Code Online (Sandbox Code Playgroud)

或这个?

#!/bin/bash
echo "Here goes my simple script that changes some settings."
# ... do some stuff
Run Code Online (Sandbox Code Playgroud)

macos bash shell terminal

4
推荐指数
1
解决办法
1万
查看次数

标签 统计

bash ×3

shell ×3

unix ×2

command-line ×1

macos ×1

sh ×1

terminal ×1