百分求助Linux常识问题

trueadou 2005-01-25 02:07:53
一直搞不清楚运行可执行文件的时候,到底加./(点斜杠)和. /加点空格斜杠有什么分别?
还有,运行可执行文件的时候一定要到它所在的目录吗?
有没有什么讲究?
请指教!
...全文
347 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
yanghuajia 2005-01-26
  • 打赏
  • 举报
回复
man bash

. filename [arguments]
source filename [arguments]
Read and execute commands from filename in the current shell
environment and return the exit status of the last command exe-
cuted from filename. If filename does not contain a slash, file
names in PATH are used to find the directory containing file-
name. The file searched for in PATH need not be executable.
When bash is not in posix mode, the current directory is
searched if no file is found in PATH. If the sourcepath option
to the shopt builtin command is turned off, the PATH is not
searched. If any arguments are supplied, they become the posi-
tional parameters when filename is executed. Otherwise the
positional parameters are unchanged. The return status is the
status of the last command exited within the script (0 if no
commands are executed), and false if filename is not found or
cannot be read.

cnepine 2005-01-26
  • 打赏
  • 举报
回复
./ 表示当前目录下 ; . / 这表示你输入的是两个目录名字,一个代表当前目录,一个代表根目录。

运行可执行文件的时候不一定要到它所在的目录下,想一下你运行ls , cp 等命令时,不是在任何路径下都可以吗?这个就是环境变量的问题。如果你把可执行程序放在/bin下,这是就不需要了。或者你设置环境变量到你所运行的目录下。
转转耳朵 2005-01-26
  • 打赏
  • 举报
回复
./(点斜杠)的意思是执行当前目录下的某可执行文件.
. /(点空格斜杠)相当于 source 根目录下的一个脚本.
source是用来执行脚本文件用的, 比如说 . ~/.bash_profile 会执行一遍~/.bash_profile
hustxxb 2005-01-25
  • 打赏
  • 举报
回复
不懂,帮顶
^_^
老猪 2005-01-25
  • 打赏
  • 举报
回复
在linux下,带点的文件名,比如.bash 一般我们输入shell>ls;dir;等都不能看到的,也算是隐藏的文件吧,所有 .,..是隐藏的文件
tengulre 2005-01-25
  • 打赏
  • 举报
回复
. /是shell脚本得一个子命令,它只能运行shell脚本。后面的 /是指shell脚本的绝对路径.
老猪 2005-01-25
  • 打赏
  • 举报
回复
给我的感觉,当你在个目录下执行
shell>ls -la
然后就会列出: .和.. 而且是目录,.表示当前目录,..表示上级目录,我觉得可以把.和..当作特殊的目录,./ 表示当前目录下,../表示上级目录下。如果你执行文件shell>./可执行文件 就是表示当前目录下的可执行文件,shell>../可执行文件,就是表示上级目录的可执行文件,而,如果你输入shell>. / 这表示你输入的是两个目录名字,一个代表当前目录,一个代表根目录。

呵呵,这是我的人为!
UP!!!!!!!!!!!!!!!!!!!!!!
autoegg 2005-01-25
  • 打赏
  • 举报
回复
关注
trueadou 2005-01-25
  • 打赏
  • 举报
回复
还有高手愿意指教吗?
iming 2005-01-25
  • 打赏
  • 举报
回复
回答你第二个问题,运行可执行文件的时候不一定要到它所在的目录,你可以引用绝对路径,如/home/User/test

19,612

社区成员

发帖
与我相关
我的任务
社区描述
系统使用、管理、维护问题。可以是Ubuntu, Fedora, Unix等等
社区管理员
  • 系统维护与使用区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧