为什么linux目录后面加斜杠,百分求助Linux常识问题

一直搞不清楚运行可执行文件的时候,到底加./(点斜杠)和. /加点空格斜杠有什么分别?

还有,运行可执行文件的时候一定要到它所在的目录吗?

有没有什么讲究?

请指教!

|

. /是shell脚本得一个子命令,它只能运行shell脚本。后面的 /是指shell脚本的绝对路径.

|

./(点斜杠)的意思是执行当前目录下的某可执行文件.

. /(点空格斜杠)相当于 source 根目录下的一个脚本.

source是用来执行脚本文件用的, 比如说 . ~/.bash_profile 会执行一遍~/.bash_profile

|

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.

|

回答你第二个问题,运行可执行文件的时候不一定要到它所在的目录,你可以引用绝对路径,如/home/User/test

|

给我的感觉,当你在个目录下执行

shell>ls -la

然后就会列出:  .和..   而且是目录,.表示当前目录,..表示上级目录,我觉得可以把.和..当作特殊的目录,./  表示当前目录下,../表示上级目录下。如果你执行文件shell>./可执行文件  就是表示当前目录下的可执行文件,shell>../可执行文件,就是表示上级目录的可执行文件,而,如果你输入shell>. /  这表示你输入的是两个目录名字,一个代表当前目录,一个代表根目录。

呵呵,这是我的人为!

UP!!!!!!!!!!!!!!!!!!!!!!

|

在linux下,带点的文件名,比如.bash 一般我们输入shell>ls;dir;等都不能看到的,也算是隐藏的文件吧,所有 .,..是隐藏的文件

|

不懂,帮顶

^_^

|

./  表示当前目录下 ; . /  这表示你输入的是两个目录名字,一个代表当前目录,一个代表根目录。

运行可执行文件的时候不一定要到它所在的目录下,想一下你运行ls , cp 等命令时,不是在任何路径下都可以吗?这个就是环境变量的问题。如果你把可执行程序放在/bin下,这是就不需要了。或者你设置环境变量到你所运行的目录下。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值